Пример #1
0
        // Token: 0x060126AB RID: 75435 RVA: 0x004BA5F4 File Offset: 0x004B87F4
        public void PassEvent <T>(PointerEventData data, ExecuteEvents.EventFunction <T> function) where T : IEventSystemHandler
        {
            if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_PassEventPointerEventDataEventFunction ` 1_hotfix != null)
            {
                this.m_PassEventPointerEventDataEventFunction ` 1_hotfix.call(new object[]
                {
                    this,
                    data,
                    function
                });
                return;
            }
            BJLuaObjHelper.IsSkipLuaHotfix = false;
            List <RaycastResult> list = new List <RaycastResult>();

            EventSystem.current.RaycastAll(data, list);
            GameObject gameObject = data.pointerCurrentRaycast.gameObject;

            for (int i = 0; i < list.Count; i++)
            {
                if (gameObject != list[i].gameObject)
                {
                    ExecuteEvents.ExecuteHierarchy <T>(list[i].gameObject, data, function);
                    break;
                }
            }
        }
Пример #2
0
    protected void PassEvent <T>(PointerEventData _Event, ExecuteEvents.EventFunction <T> _Function) where T : IEventSystemHandler
    {
        if (_Event == null || _Event.used)
        {
            return;
        }

        EventSystem.current.RaycastAll(_Event, m_RaycastResults);

        GameObject target = null;

        foreach (RaycastResult raycastResult in m_RaycastResults)
        {
            if (raycastResult.gameObject == gameObject)
            {
                continue;
            }

            target = raycastResult.gameObject;

            break;
        }

        if (target == null)
        {
            return;
        }

        ExecuteEvents.Execute(target, _Event, _Function);
    }
Пример #3
0
    private void PassEvent <T>(PointerEventData data, ExecuteEvents.EventFunction <T> function)
        where T : IEventSystemHandler
    {
        List <RaycastResult> results = new List <RaycastResult>();

        EventSystem.current.RaycastAll(data, results);
        GameObject current = data.pointerCurrentRaycast.gameObject;

        if (results.Count > 0 && svobj == null)
        {
            for (int i = 0; i < results.Count; i++)
            {
                if (current != results[i].gameObject)
                {
                    if ((results[i].gameObject.name == "Scroll View") && svobj == null)
                    {
                        svobj = results[i].gameObject;
                        ExecuteEvents.Execute(results[i].gameObject, data, function);
                    }
                    else if (svobj != null)
                    {
                        ExecuteEvents.Execute(svobj, data, function);
                    }
                }
            }
        }
        else
        {
            if (svobj != null)
            {
                ExecuteEvents.Execute(svobj, data, function);
            }
        }
    }
Пример #4
0
    //把事件透下去
    public void PassEvent <T>(PointerEventData data, ExecuteEvents.EventFunction <T> function)
        where T : IEventSystemHandler
    {
        List <RaycastResult> results = new List <RaycastResult>();

        EventSystem.current.RaycastAll(data, results);
        GameObject current = data.pointerCurrentRaycast.gameObject;

        Debug.Log("把事件透下去" + results.Count);
        for (int i = 0; i < results.Count; i++)
        {
            Debug.Log("results[i].gameObject=" + results[i].gameObject.name);

            if (current != results[i].gameObject)
            {
                Button btn = results[i].gameObject.GetComponent <Button>();
                if (btn != null)
                {
                    Debug.Log("进来了几次");
                    ExecuteEvents.Execute(results[i].gameObject, data, function);
                    //RaycastAll后ugui会自己排序,如果你只想响应透下去的最近的一个响应,这里ExecuteEvents.Execute后直接break就行。
                    break;
                }
            }
        }
    }
Пример #5
0
        /// <summary>
        /// 向上穿透一级指定类型的事件
        /// </summary>
        /// <param name="eventData">Event data.</param>
        /// <param name="functor">Functor.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        private void PassEvent <T> (PointerEventData eventData, ExecuteEvents.EventFunction <T> functor) where T : IEventSystemHandler
        {
            List <RaycastResult> results = new List <RaycastResult> ();

            EventSystem.current.RaycastAll(eventData, results);

            bool selfFounded = false;

            foreach (RaycastResult result in results)
            {
                if (result.gameObject == gameObject)
                {
                    // 先找到自己
                    selfFounded = true;
                }
                else if (selfFounded)
                {
                    // 然后向上穿透一级
                    GameObject go = ExecuteEvents.ExecuteHierarchy(result.gameObject, eventData, functor);
                    if (go != null)
                    {
                        break;
                    }
                }
            }
        }
Пример #6
0
 /// <summary>
 /// Swipe 이벤트 실행
 /// </summary>
 /// <param name="function"></param>
 public void ExecuteSwipeEvent(ExecuteEvents.EventFunction <IFSNSwipeHandler> function)
 {
     foreach (var handler in m_swipeHandlers)
     {
         ExecuteEvents.ExecuteHierarchy <IFSNSwipeHandler>(handler, null, function);
     }
 }
Пример #7
0
        public static void PassEvent <T>(string btnName, PointerEventData data, ExecuteEvents.EventFunction <T> function, bool isClick) where T : IEventSystemHandler
        {
            List <RaycastResult> results = new List <RaycastResult>();

            EventSystem.current.RaycastAll(data, results);

            GameObject current = data.pointerCurrentRaycast.gameObject;

            for (int i = 0; i < results.Count; i++)
            {
                GameObject resultGameObject = results[i].gameObject;
                if (current != resultGameObject)
                {
                    if (isClick)
                    {
                        if (resultGameObject.name.Equals(btnName))
                        {
                            ExecuteEvents.Execute(results[i].gameObject, data, function);
                            break;
                        }
                    }
                    else
                    {
                        ExecuteEvents.Execute(results[i].gameObject, data, function);
                    }
                }
            }
        }
Пример #8
0
        //把事件透下去
        public void PassEvent <T>(PointerEventData data, ExecuteEvents.EventFunction <T> function)
            where T : IEventSystemHandler
        {
            List <RaycastResult> results = new List <RaycastResult>();

            EventSystem.current.RaycastAll(data, results);
            GameObject current = data.pointerCurrentRaycast.gameObject;

            for (int i = 0; i < results.Count; i++)
            {
                var nextTarget = results[i].gameObject;
                if (current != nextTarget)
                {
                    //新建立一个事件数据。。保证PointerEventData是正常的
                    var eventData = new PointerEventData(EventSystem.current);
                    eventData.rawPointerPress = data.rawPointerPress;
                    eventData.pointerPress    = nextTarget;
                    eventData.pointerEnter    = nextTarget;
                    eventData.pointerDrag     = nextTarget;
                    ExecuteEvents.Execute(nextTarget, eventData, function);
                    //RaycastAll后ugui会自己排序,如果你只想响应透下去的最近的一个响应,这里ExecuteEvents.Execute后直接break就行。
                    break;
                }
            }
        }
Пример #9
0
    //把事件透下去
    public void PassEvent <T>(PointerEventData data, ExecuteEvents.EventFunction <T> function) where T : IEventSystemHandler
    {
        List <RaycastResult> results = new List <RaycastResult>();

        EventSystem.current.RaycastAll(data, results);
        bool findCurrent = false;

        for (int i = 0; i < results.Count; i++)
        {
            if (!findCurrent && gameObject == results[i].gameObject)
            {
                findCurrent = true;
                continue;
            }

            if (findCurrent)
            {
                ExecuteEvents.Execute(results[i].gameObject, data, function);
                break;
                //RaycastAll后ugui会自己排序,如果你只想响应透下去的最近的一个响应,这里ExecuteEvents.Execute后直接break就行。
            }
        }

        if (!findCurrent && results.Count > 0)
        {
            ExecuteEvents.Execute(results[0].gameObject, data, function);
        }
    }
Пример #10
0
    ////监听按下
    //public void OnPointerDown(PointerEventData eventData)
    //{
    //    PassEvent(eventData, ExecuteEvents.pointerDownHandler);
    //}
    ////监听点击
    //public void OnPointerClick(PointerEventData eventData)
    //{
    //    PassEvent(eventData, ExecuteEvents.submitHandler);
    //    PassEvent(eventData, ExecuteEvents.pointerClickHandler);
    //}

    //把事件透下去
    public void PassEvent <T>(PointerEventData data, ExecuteEvents.EventFunction <T> function)
        where T : IEventSystemHandler
    {
        Vector2 position = Vector2.zero;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, data.position, data.enterEventCamera, out position);
        float length = Vector2.Distance(position, center);

        if (diameter < length)
        {
            return;
        }

        List <RaycastResult> results = new List <RaycastResult>();

        EventSystem.current.RaycastAll(data, results);
        GameObject current = data.pointerCurrentRaycast.gameObject;

        for (int i = 0; i < results.Count; i++)
        {
            if (current != results[i].gameObject)
            {
                ExecuteEvents.Execute(results[i].gameObject, data, function);
                return;
            }
        }
    }
Пример #11
0
    //事件传递
    public void PassEvent <T>(PointerEventData data, ExecuteEvents.EventFunction <T> function)
        where T : IEventSystemHandler
    {
        List <RaycastResult> results = new List <RaycastResult>();

        //RaycastAll:射出一条射线并返回所有碰撞,返回的是RaycastHit[]结构体
        //射线不会检测到ui
        //ui直接渲染在屏幕上
        EventSystem.current.RaycastAll(data, results);
        //results里面都是拥有  碰撞体  的物体、ui
        GameObject current = data.pointerCurrentRaycast.gameObject;

        for (int i = 0; i < results.Count; i++)
        {
            Debug.Log("------" + results[i].gameObject.name + "------");
            if (current != results[i].gameObject)
            {
                ExecuteEvents.Execute(results[i].gameObject, data, function);
                Debug.Log("******" + current.gameObject.name + "******");
                break;
                //RaycastAll后ugui会自己排序,如果你只想响应透下去的最近的一个响应,这里ExecuteEvents.Execute后直接break就行。
            }
            //else
            //{
            //    Debug.Log("不是collider");
            //}
        }
    }
Пример #12
0
 public static void Execute <T>(PointerEventData baseData, ExecuteEvents.EventFunction <T> eventFunction, List <GameObject> results) where T : IEventSystemHandler
 {
     foreach (var item in results)
     {
         ExecuteEvents.Execute(item, baseData, eventFunction);
     }
 }
Пример #13
0
        public static bool Execute <T>(GameObject target, BaseEventData eventData, ExecuteEvents.EventFunction <T> functor) where T : IEventSystemHandler
        {
            List <IEventSystemHandler> element = ExecuteEvents.s_HandlerListPool.Get();

            ExecuteEvents.GetEventList <T>(target, (IList <IEventSystemHandler>)element);
            for (int index = 0; index < element.Count; ++index)
            {
                T handler;
                try
                {
                    handler = (T)element[index];
                }
                catch (Exception ex)
                {
                    Debug.LogException(new Exception(string.Format("Type {0} expected {1} received.", (object)typeof(T).Name, (object)element[index].GetType().Name), ex));
                    continue;
                }
                try
                {
                    functor(handler, eventData);
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }
            int count = element.Count;

            ExecuteEvents.s_HandlerListPool.Release(element);
            return(count > 0);
        }
Пример #14
0
        public void HandleEvent <T>(BaseEventData eventData, ExecuteEvents.EventFunction <T> eventHandler)
            where T : IEventSystemHandler
        {
            if (!Instance.enabled || disabledRefCount > 0)
            {
                return;
            }

            // Use focused object when OverrideFocusedObject is null.
            GameObject focusedObject = (OverrideFocusedObject == null) ? GazeManager.Instance.HitObject : OverrideFocusedObject;

            // Send the event to global listeners
            for (int i = 0; i < globalListeners.Count; i++)
            {
                // Global listeners should only get events on themselves, as opposed to their hierarchy
                ExecuteEvents.Execute(globalListeners[i], eventData, eventHandler);
            }

            // Handle modal input if one exists
            if (modalInputStack.Count > 0)
            {
                GameObject modalInput = modalInputStack.Peek();

                // If there is a focused object in the hierarchy of the modal handler, start the event
                // bubble there
                if (focusedObject != null && modalInput != null && focusedObject.transform.IsChildOf(modalInput.transform))
                {
                    if (ExecuteEvents.ExecuteHierarchy(focusedObject, eventData, eventHandler))
                    {
                        return;
                    }
                }
                // Otherwise, just invoke the event on the modal handler itself
                else
                {
                    if (ExecuteEvents.ExecuteHierarchy(modalInput, eventData, eventHandler))
                    {
                        return;
                    }
                }
            }

            // If event was not handled by modal, pass it on to the current focused object
            if (focusedObject != null)
            {
                bool eventHandled = ExecuteEvents.ExecuteHierarchy(focusedObject, eventData, eventHandler);
                if (eventHandled)
                {
                    return;
                }
            }

            // If event was not handled by the focused object, pass it on to any fallback handlers
            if (fallbackInputStack.Count > 0)
            {
                GameObject fallbackInput = fallbackInputStack.Peek();
                ExecuteEvents.ExecuteHierarchy(fallbackInput, eventData, eventHandler);
            }
        }
Пример #15
0
 public static void Execute <T>(BaseEventData eventData, ExecuteEvents.EventFunction <T> function)
     where T : IEventSystemHandler
 {
     foreach (var listener in _listeners)
     {
         ExecuteEvents.Execute(listener, eventData, function);
     }
 }
 void SendMessage <T>(InputTarget targetControl, GameObject target, ExecuteEvents.EventFunction <T> handler)
     where T : IEventSystemHandler
 {
     if (HInput.Devices.Any(device => device[targetControl].WasPressed))
     {
         ExecuteEvents.Execute(target, GetBaseEventData(), handler);
     }
 }
Пример #17
0
 static ExecuteFunctions()
 {
     s_keyDownHandler      = Execute;
     s_keyHoldHandler      = Execute;
     s_keyBeginHoldHandler = Execute;
     s_keyEndHoldHandler   = Execute;
     s_keyUpHandler        = Execute;
 }
Пример #18
0
 void ExecuteEvent <T>(ExecuteEvents.EventFunction <T> functor) where T : IEventSystemHandler
 {
     if (ActiveButton != null)
     {
         var pointer = new PointerEventData(EventSystem.current);
         ExecuteEvents.Execute(ActiveButton.gameObject, pointer, functor);
     }
 }
Пример #19
0
        public static void PassEvent <T>(string btnName, PointerEventData data, ExecuteEvents.EventFunction <T> function, bool isClick, int clickType = 0) where T : IEventSystemHandler
        {
            List <RaycastResult> results = new List <RaycastResult>();

            EventSystem.current.RaycastAll(data, results);

            GameObject current = data.pointerCurrentRaycast.gameObject;

            for (int i = 0; i < results.Count; i++)
            {
                GameObject resultGameObject = results[i].gameObject;
                if (current != resultGameObject)
                {
                    if (isClick)
                    {
                        if (resultGameObject.name.Equals(btnName))
                        {
                            GameObject resultObj = results[i].gameObject;
                            if (clickType == 0)
                            {
                                if (resultObj.GetComponent <UnityEngine.UI.Toggle>() != null)
                                {
                                    ExecuteEvents.Execute(resultObj, data, function);
                                    return;
                                }
                                GOGUI.EventTriggerListener eventListener = GOGUI.EventTriggerListener.Get(resultObj);
                                if (eventListener == null)
                                {
                                    eventListener = GOGUI.EventTriggerListener.Get(resultObj.transform.parent);
                                }
                                eventListener.OnClick();
                                return;
                            }
                            else if (clickType == 1)
                            {
                                ExecuteEvents.Execute(resultObj, data, function);
                                GOGUI.EventTriggerListener eventListener = GOGUI.EventTriggerListener.Get(resultObj);
                                if (eventListener == null)
                                {
                                    eventListener = GOGUI.EventTriggerListener.Get(resultObj.transform.parent);
                                }
                                eventListener.OnLongPressBegin();
                            }
                            else if (clickType == 2)
                            {
                                GOGUI.EventTriggerListener eventListener = GOGUI.EventTriggerListener.Get(resultObj);
                                if (eventListener == null)
                                {
                                    eventListener = GOGUI.EventTriggerListener.Get(resultObj.transform.parent);
                                }
                                eventListener.OnMyLongPressEnd();
                                //ExecuteEvents.Execute(resultObj, data, ExecuteEvents.pointerUpHandler);
                            }
                        }
                    }
                }
            }
        }
Пример #20
0
        public static void postChildren <T>(GameObject root, ExecuteEvents.EventFunction <T> func) where T : IEventSystemHandler
        {
            var lst = root.GetComponentsInChildren <MonoBehaviour>().Where(a => a is T).ToArray();

            foreach (var child in lst)
            {
                ExecuteEvents.Execute <T>(child.gameObject, null, func);
            }
        }
Пример #21
0
    /// <summary>
    /// 전환 스킵 이벤트 호출
    /// </summary>
    /// <param name="function"></param>
    public void ExecuteSkipTransitionEvent(ExecuteEvents.EventFunction <IFSNSkipTransitionHandler> function)
    {
        // NOTE : 현재는 swipe handler 와 통합해서 사용중임. 나중에 분리해야할 때 분리할 것

        foreach (var handler in m_swipeHandlers)
        {
            ExecuteEvents.ExecuteHierarchy <IFSNSkipTransitionHandler>(handler, null, function);
        }
    }
 public static void Execute <T>(GameObject target, BaseEventData eventData, ExecuteEvents.EventFunction <T> functor)
     where T : IEventSystemHandler
 {
     if (!target)
     {
         return;
     }
     ExecuteEvents.Execute(target, eventData, functor);
 }
Пример #23
0
        // Token: 0x06010461 RID: 66657 RVA: 0x00440590 File Offset: 0x0043E790
        public void PassEvent <T>(PointerEventData data, ExecuteEvents.EventFunction <T> function) where T : IEventSystemHandler
        {
            if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_PassEventPointerEventDataEventFunction ` 1_hotfix != null)
            {
                this.m_PassEventPointerEventDataEventFunction ` 1_hotfix.call(new object[]
                {
                    this,
                    data,
                    function
                });
                return;
            }
            BJLuaObjHelper.IsSkipLuaHotfix = false;
            List <RaycastResult> list = new List <RaycastResult>();

            EventSystem.current.RaycastAll(data, list);
            GameObject gameObject = data.pointerCurrentRaycast.gameObject;

            if (gameObject == null && list.Count == 0 && this.m_draggingGo != null)
            {
                ExecuteEvents.ExecuteHierarchy <T>(this.m_draggingGo, data, function);
                return;
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (gameObject != list[i].gameObject)
                {
                    if (!list[i].gameObject.transform.IsChildOf(base.gameObject.transform))
                    {
                        GameObject root;
                        if (typeof(T) == typeof(IBeginDragHandler))
                        {
                            this.m_draggingGo = list[i].gameObject;
                            root = this.m_draggingGo;
                            this.m_isDragging = (this.m_draggingGo.GetComponentInParent <ScrollRect>() != null);
                        }
                        else if (typeof(T) == typeof(IDragHandler))
                        {
                            root = this.m_draggingGo;
                        }
                        else if (typeof(T) == typeof(IEndDragHandler))
                        {
                            this.m_isDragging = false;
                            root = this.m_draggingGo;
                            this.m_draggingGo = null;
                        }
                        else
                        {
                            root = list[i].gameObject;
                        }
                        ExecuteEvents.ExecuteHierarchy <T>(root, data, function);
                        break;
                    }
                }
            }
        }
Пример #24
0
    public GameObject ExecuteHierarchy <T>(GameObject root,
                                           BaseEventData eventData,
                                           ExecuteEvents.EventFunction <T> callbackFunction)
        where T : IEventSystemHandler
    {
        GameObject result = ExecuteEvents.ExecuteHierarchy <T>(root, eventData, callbackFunction);

        CallEventDelegate <T>(root, eventData);

        return(result);
    }
Пример #25
0
    public bool Execute <T>(GameObject target,
                            BaseEventData eventData,
                            ExecuteEvents.EventFunction <T> functor)
        where T : IEventSystemHandler
    {
        bool result = ExecuteEvents.Execute <T>(target, eventData, functor);

        CallEventDelegate <T>(target, eventData);

        return(result);
    }
Пример #26
0
 public void ExecuteEvent <T>(BaseEventData eventData, ExecuteEvents.EventFunction <T> functor) where T : IEventSystemHandler
 {
     foreach (GameObject subscriber in m_subscribers)
     {
         //filter subscriber list by their event interface implementation
         if (subscriber.GetComponent <T>() != null)
         {
             ExecuteEvents.Execute <T>(subscriber, eventData, functor);
         }
     }
 }
Пример #27
0
        /// <inheritdoc />
        public override void HandleEvent <T>(BaseEventData eventData, ExecuteEvents.EventFunction <T> eventHandler)
        {
            Debug.Assert(eventData != null);
            var teleportData = ExecuteEvents.ValidateEventData <TeleportEventData>(eventData);

            Debug.Assert(teleportData != null);
            Debug.Assert(!teleportData.used);

            // Process all the event listeners
            base.HandleEvent(teleportData, eventHandler);
        }
Пример #28
0
        /// <inheritdoc />
        public virtual void HandleEvent <T>(BaseEventData eventData, ExecuteEvents.EventFunction <T> eventHandler) where T : IEventSystemHandler
        {
            Debug.Assert(!eventData.used);
            eventExecutionDepth++;

            for (int i = EventListeners.Count - 1; i >= 0; i--)
            {
                ExecuteEvents.Execute(EventListeners[i], eventData, eventHandler);
            }

            eventExecutionDepth--;
        }
        /// <inheritdoc />
        public virtual void HandleEvent <T>(BaseEventData eventData, ExecuteEvents.EventFunction <T> eventHandler) where T : IEventSystemHandler
        {
            Debug.Assert(!eventData.used);
            isExecutingEvents = true;

            for (int i = 0; i < EventListeners.Count; i++)
            {
                ExecuteEvents.Execute(EventListeners[i], eventData, eventHandler);
            }

            isExecutingEvents = false;
        }
Пример #30
0
        /// <summary>
        /// Send a message to all targets with a handler of type T
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Data"></param>
        /// <param name="functor"></param>
        public static void Send <T>(ExecuteEvents.EventFunction <T> functor) where T : ISystemMessageTarget
        {
            BaseEventData Data = new BaseEventData(EventSystem.current);

            foreach (var t in Targets)
            {
                if (ExecuteEvents.CanHandleEvent <T>(t))
                {
                    ExecuteEvents.Execute <T>(t, Data, functor);
                }
            }
        }