Unity UGUI事件接口(EventSystems接口)

事件接口的触发条件

using UnityEngine.EventSystems;

        /// 
        /// 指针点击事件
        /// *在组件可视的区域按下且抬起时指针处于区域内(按下离开区域后抬起不会触发)
        /// 
        /// 
        public virtual void OnPointerClick(PointerEventData eventData) { }
        /// 
        /// 指针按下事件
        /// 
        /// 
        public virtual void OnPointerDown(PointerEventData eventData) { }
        /// 
        /// 指针进入事件
        /// 
        /// 
        public virtual void OnPointerEnter(PointerEventData eventData) { }
        /// 
        /// 指针离开事件
        /// 
        /// 
        public virtual void OnPointerExit(PointerEventData eventData) { }
        /// 
        /// 指针抬起事件
        /// 
        /// 
        public virtual void OnPointerUp(PointerEventData eventData) { }

        /// 
        /// 初始化潜在的拖动事件
        /// *(必须实现IDragHandler接口)与IPointerDownHandler事件触发条件大致相同
        /// 
        /// 
        public virtual void OnInitializePotentialDrag(PointerEventData eventData) { }
        /// 
        /// 拖动开始事件
        /// 
        /// 
        public virtual void OnBeginDrag(PointerEventData eventData) { }
        /// 
        /// 拖动中事件
        /// 
        /// 
        public virtual void OnDrag(PointerEventData eventData) { }
        /// 
        /// 拖动结束事件
        /// 
        /// 
        public virtual void OnEndDrag(PointerEventData eventData) { }
        /// 
        /// 接收拖动事件
        /// *接受实现IDragHandler接口的组件拖动到本组件上面松开时触发
        /// 
        /// 
        public virtual void OnDrop(PointerEventData eventData) { }
        /// 
        /// 滚动事件
        /// *滑轮在上面滚动时触发
        /// 
        /// 
        public virtual void OnScroll(PointerEventData eventData) { }


        #region InputManager关联组事件(同选择组要求)
        /// 
        /// 移动事件(上下左右)
        /// *与InputManager里的Horizontal和Vertical按键相对应。Input.GetAxisRaw
        /// 
        /// 
        public virtual void OnMove(AxisEventData eventData) { }
        /// 
        /// 取消事件
        ///  *按下InputManager里的Cancel对应的按键(PC、Mac默认:Esc键)。Input.GetButtonDown
        /// 
        /// 
        public virtual void OnCancel(BaseEventData eventData) { }
        /// 
        /// 提交事件
        /// *按下InputManager里的Submit对应的按键(PC、Mac默认:Enter键)。Input.GetButtonDown
        /// 
        /// 
        public virtual void OnSubmit(BaseEventData eventData) { } 
        #endregion

        #region 选择组事件  
        /*必须设置选择对象后才能触发
         * EventSystem.current.SetSelectedGameObject(gameobject)  
         */
        /// 
        /// 选择事件
        /// 
        /// 
        public virtual void OnSelect(BaseEventData eventData) { }
        /// 
        /// 取消选择事件
        /// 
        /// 
        public virtual void OnDeselect(BaseEventData eventData) { }
        /// 
        /// 选中物体每帧触发事件
        /// 
        /// 
        public virtual void OnUpdateSelected(BaseEventData eventData) { } 
        #endregion

 

 

你可能感兴趣的:(萌新备忘录,unity3d,Unity)