// 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; } } }
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); }
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); } } }
//把事件透下去 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; } } } }
/// <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; } } } }
/// <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); } }
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); } } } }
//把事件透下去 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; } } }
//把事件透下去 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); } }
////监听按下 //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; } } }
//事件传递 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"); //} } }
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); } }
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); }
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); } }
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); } }
static ExecuteFunctions() { s_keyDownHandler = Execute; s_keyHoldHandler = Execute; s_keyBeginHoldHandler = Execute; s_keyEndHoldHandler = Execute; s_keyUpHandler = Execute; }
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); } }
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); } } } } } }
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); } }
/// <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); }
// 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; } } } }
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); }
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); }
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); } } }
/// <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); }
/// <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; }
/// <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); } } }