unity使用IDragHandler实现拖拽
来源:互联网 发布:电商销售记录数据 编辑:程序博客网 时间:2024/06/05 09:17
先引入命名空间 UnityEngine.EventSystems,然后引入接口IDragHandler,IBeginDragHandler
Vector3 worldPos;
Vector3 offset;public void OnBeginDrag(PointerEventData eventData)
{
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(transform.GetComponent<RectTransform>(), Input.mousePosition
, eventData.enterEventCamera, out worldPos))
{
offset = transform.position - worldPos;
}
}
public void OnDrag(PointerEventData eventData)
{
transform.position = offset + Input.mousePosition;
}
其中EventSystems还有如下功能
- IPointerEnterHandler - OnPointerEnter - Called when a pointer enters the object
- IPointerExitHandler - OnPointerExit - Called when a pointer exits the object
- IPointerDownHandler - OnPointerDown - Called when a pointer is pressed on the object
- IPointerUpHandler - OnPointerUp - Called when a pointer is released (called on the original the pressed object)
- IPointerClickHandler - OnPointerClick - Called when a pointer is pressed and released on the same object
- IInitializePotentialDragHandler - OnInitializePotentialDrag - Called when a drag target is found, can be used to initialise values
- IBeginDragHandler - OnBeginDrag - Called on the drag object when dragging is about to begin
- IDragHandler - OnDrag - Called on the drag object when a drag is happening
- IEndDragHandler - OnEndDrag - Called on the drag object when a drag finishes
- IDropHandler - OnDrop - Called on the object where a drag finishes
- IScrollHandler - OnScroll - Called when a mouse wheel scrolls
- IUpdateSelectedHandler - OnUpdateSelected - Called on the selected object each tick
- ISelectHandler - OnSelect - Called when the object becomes the selected object
- IDeselectHandler - OnDeselect - Called on the selected object becomes deselected
- IMoveHandler - OnMove - Called when a move event occurs (left, right, up, down, ect)
- ISubmitHandler - OnSubmit - Called when the submit button is pressed
- ICancelHandler - OnCancel - Called when the cancel button is pressed
阅读全文
0 0
- unity使用IDragHandler实现拖拽
- 关于UGUI实现拖拽功能的接口(IBeginDragHandler、IEndDragHandler、IDragHandler )需注意的问题
- unity实现拖拽
- [unity]NGUI实现背包拖拽+使用EventDelegate回调
- 10.17 阴 周三 熟悉了拖拽IBeginDragHandler、IDragHandler、和IEndDragHandler这三个接口的应用 以及技能消耗品冷却效果
- 使用Unity 实现 AOP
- 使用Unity 实现 AOP
- Unity实现拖拽功能
- 使用Unity 实现依赖注入
- 使用Unity 实现依赖注入
- 使用Unity实现时光倒流
- 使用Unity 实现依赖注入
- Unity基于NGUI实现拖拽功能
- Unity学习之实现拖拽功能
- Unity UGUI 实现简单拖拽功能
- Unity UGUI 拖拽跟随实现
- Unity 实现鼠标拖拽查看地图
- 使用Unity.Mvc3实现依赖注入简介
- Owin中间件动手做
- POWERBI连接Mysql数据库:错误:需要安装一个或多个组件
- c/c++课堂笔记——字符串的基本操作
- webots自学笔记(三)控制器与电机控制
- 心好累
- unity使用IDragHandler实现拖拽
- java.lang.NoClassDefFoundError: Failed resolution of: Lio/bugtags/agent/instrumentation/okhttp3/OkHt
- linux中tomcat中https配置
- jQuery学习笔记之Ajax用法详解
- 关掉模块的验证CONFIG_MODULE_SIG
- 极大似然估计(MLE)和最大后验估计(MAP)
- linux中用到的一些思想
- Mintty(Cygwin)快速定位当前目录
- OpenStack Horizon源代码分析-用户登录全过程