概述
事件接口的触发条件
using UnityEngine.EventSystems;
/// <summary>
/// 指针点击事件
/// *在组件可视的区域按下且抬起时指针处于区域内(按下离开区域后抬起不会触发)
/// </summary>
/// <param name="eventData"></param>
public virtual void OnPointerClick(PointerEventData eventData) { }
/// <summary>
/// 指针按下事件
/// </summary>
/// <param name="eventData"></param>
public virtual void OnPointerDown(PointerEventData eventData) { }
/// <summary>
/// 指针进入事件
/// </summary>
/// <param name="eventData"></param>
public virtual void OnPointerEnter(PointerEventData eventData) { }
/// <summary>
/// 指针离开事件
/// </summary>
/// <param name="eventData"></param>
public virtual void OnPointerExit(PointerEventData eventData) { }
/// <summary>
/// 指针抬起事件
/// </summary>
/// <param name="eventData"></param>
public virtual void OnPointerUp(PointerEventData eventData) { }
/// <summary>
/// 初始化潜在的拖动事件
/// *(必须实现IDragHandler接口)与IPointerDownHandler事件触发条件大致相同
/// </summary>
/// <param name="eventData"></param>
public virtual void OnInitializePotentialDrag(PointerEventData eventData) { }
/// <summary>
/// 拖动开始事件
/// </summary>
/// <param name="eventData"></param>
public virtual void OnBeginDrag(PointerEventData eventData) { }
/// <summary>
/// 拖动中事件
/// </summary>
/// <param name="eventData"></param>
public virtual void OnDrag(PointerEventData eventData) { }
/// <summary>
/// 拖动结束事件
/// </summary>
/// <param name="eventData"></param>
public virtual void OnEndDrag(PointerEventData eventData) { }
/// <summary>
/// 接收拖动事件
/// *接受实现IDragHandler接口的组件拖动到本组件上面松开时触发
/// </summary>
/// <param name="eventData"></param>
public virtual void OnDrop(PointerEventData eventData) { }
/// <summary>
/// 滚动事件
/// *滑轮在上面滚动时触发
/// </summary>
/// <param name="eventData"></param>
public virtual void OnScroll(PointerEventData eventData) { }
#region InputManager关联组事件(同选择组要求)
/// <summary>
/// 移动事件(上下左右)
/// *与InputManager里的Horizontal和Vertical按键相对应。Input.GetAxisRaw
/// </summary>
/// <param name="eventData"></param>
public virtual void OnMove(AxisEventData eventData) { }
/// <summary>
/// 取消事件
/// *按下InputManager里的Cancel对应的按键(PC、Mac默认:Esc键)。Input.GetButtonDown
/// </summary>
/// <param name="eventData"></param>
public virtual void OnCancel(BaseEventData eventData) { }
/// <summary>
/// 提交事件
/// *按下InputManager里的Submit对应的按键(PC、Mac默认:Enter键)。Input.GetButtonDown
/// </summary>
/// <param name="eventData"></param>
public virtual void OnSubmit(BaseEventData eventData) { }
#endregion
#region 选择组事件
/*必须设置选择对象后才能触发
* EventSystem.current.SetSelectedGameObject(gameobject)
*/
/// <summary>
/// 选择事件
/// </summary>
/// <param name="eventData"></param>
public virtual void OnSelect(BaseEventData eventData) { }
/// <summary>
/// 取消选择事件
/// </summary>
/// <param name="eventData"></param>
public virtual void OnDeselect(BaseEventData eventData) { }
/// <summary>
/// 选中物体每帧触发事件
/// </summary>
/// <param name="eventData"></param>
public virtual void OnUpdateSelected(BaseEventData eventData) { }
#endregion
最后
以上就是贪玩书包为你收集整理的Unity UGUI事件接口(EventSystems接口)的全部内容,希望文章能够帮你解决Unity UGUI事件接口(EventSystems接口)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复