protected static FindCommonRoot ( |
||
g1 | ||
g2 | ||
Résultat |
protected void HandlePointerExitAndEnter(PointerEventData currentPointerData, GameObject newEnterTarget) { /* called in * StandaloneInputModule * ProcessTouchPress * ProcessMousePress * PointerInputModule * ProcessMove * ClearSelection * sets PointerEventData.pointerEnter * call OnPointerEnter and/or OnPointerExit depending on what is under the pointer * OnPointerEnter is called on only the first one that catches raycast * OnPointerExit is called either on the fist or all of in the stack * update hovered stack */ if (newEnterTarget == null || currentPointerData.pointerEnter == null) { for (int i = 0; i < currentPointerData.hovered.Count; i++) { ExecuteEvents.Execute <IPointerExitHandler>(currentPointerData.hovered[i], currentPointerData, ExecuteEvents.pointerExitHandler); } currentPointerData.hovered.Clear(); if (newEnterTarget == null) { currentPointerData.pointerEnter = newEnterTarget; return; } } /*newEnterTarget != null*/ if (!(currentPointerData.pointerEnter == newEnterTarget) || !newEnterTarget) /*pointerEnter is something other than newEnter target, or null*/ { GameObject gameObject = BaseInputModule.FindCommonRoot(currentPointerData.pointerEnter, newEnterTarget); if (currentPointerData.pointerEnter != null) { Transform transform = currentPointerData.pointerEnter.transform; while (transform != null) { if (gameObject != null && gameObject.transform == transform) { break; } ExecuteEvents.Execute <IPointerExitHandler>(transform.gameObject, currentPointerData, ExecuteEvents.pointerExitHandler); currentPointerData.hovered.Remove(transform.gameObject); transform = transform.parent; } } currentPointerData.pointerEnter = newEnterTarget; if (newEnterTarget != null) { Transform transform2 = newEnterTarget.transform; while (transform2 != null && transform2.gameObject != gameObject) { ExecuteEvents.Execute <IPointerEnterHandler>(transform2.gameObject, currentPointerData, ExecuteEvents.pointerEnterHandler); currentPointerData.hovered.Add(transform2.gameObject); transform2 = transform2.parent; } } } }
protected void HandlePointerExitAndEnter(PointerEventData currentPointerData, GameObject newEnterTarget) { if (newEnterTarget == null || currentPointerData.pointerEnter == null) { for (int i = 0; i < currentPointerData.hovered.Count; i++) { ExecuteEvents.Execute <IPointerExitHandler>(currentPointerData.hovered[i], currentPointerData, ExecuteEvents.pointerExitHandler); } currentPointerData.hovered.Clear(); if (newEnterTarget == null) { currentPointerData.pointerEnter = newEnterTarget; return; } } if (!(currentPointerData.pointerEnter == newEnterTarget) || !newEnterTarget) { GameObject gameObject = BaseInputModule.FindCommonRoot(currentPointerData.pointerEnter, newEnterTarget); if (currentPointerData.pointerEnter != null) { Transform transform = currentPointerData.pointerEnter.transform; while (transform != null) { if (gameObject != null && gameObject.transform == transform) { break; } ExecuteEvents.Execute <IPointerExitHandler>(transform.gameObject, currentPointerData, ExecuteEvents.pointerExitHandler); currentPointerData.hovered.Remove(transform.gameObject); transform = transform.parent; } } currentPointerData.pointerEnter = newEnterTarget; if (newEnterTarget != null) { Transform transform2 = newEnterTarget.transform; while (transform2 != null && transform2.gameObject != gameObject) { ExecuteEvents.Execute <IPointerEnterHandler>(transform2.gameObject, currentPointerData, ExecuteEvents.pointerEnterHandler); currentPointerData.hovered.Add(transform2.gameObject); transform2 = transform2.parent; } } } }
/// <summary> /// /// <para> /// Handle sending enter and exit events when a new enter targer is found. /// </para> /// /// </summary> /// <param name="currentPointerData"/><param name="newEnterTarget"/> protected void HandlePointerExitAndEnter(PointerEventData currentPointerData, GameObject newEnterTarget) { if ((UnityEngine.Object)newEnterTarget == (UnityEngine.Object)null || (UnityEngine.Object)currentPointerData.pointerEnter == (UnityEngine.Object)null) { for (int index = 0; index < currentPointerData.hovered.Count; ++index) { ExecuteEvents.Execute <IPointerExitHandler>(currentPointerData.hovered[index], (BaseEventData)currentPointerData, ExecuteEvents.pointerExitHandler); } currentPointerData.hovered.Clear(); if ((UnityEngine.Object)newEnterTarget == (UnityEngine.Object)null) { currentPointerData.pointerEnter = newEnterTarget; return; } } if ((UnityEngine.Object)currentPointerData.pointerEnter == (UnityEngine.Object)newEnterTarget && (bool)((UnityEngine.Object)newEnterTarget)) { return; } GameObject commonRoot = BaseInputModule.FindCommonRoot(currentPointerData.pointerEnter, newEnterTarget); if ((UnityEngine.Object)currentPointerData.pointerEnter != (UnityEngine.Object)null) { for (Transform transform = currentPointerData.pointerEnter.transform; (UnityEngine.Object)transform != (UnityEngine.Object)null && (!((UnityEngine.Object)commonRoot != (UnityEngine.Object)null) || !((UnityEngine.Object)commonRoot.transform == (UnityEngine.Object)transform)); transform = transform.parent) { ExecuteEvents.Execute <IPointerExitHandler>(transform.gameObject, (BaseEventData)currentPointerData, ExecuteEvents.pointerExitHandler); currentPointerData.hovered.Remove(transform.gameObject); } } currentPointerData.pointerEnter = newEnterTarget; if (!((UnityEngine.Object)newEnterTarget != (UnityEngine.Object)null)) { return; } for (Transform transform = newEnterTarget.transform; (UnityEngine.Object)transform != (UnityEngine.Object)null && (UnityEngine.Object)transform.gameObject != (UnityEngine.Object)commonRoot; transform = transform.parent) { ExecuteEvents.Execute <IPointerEnterHandler>(transform.gameObject, (BaseEventData)currentPointerData, ExecuteEvents.pointerEnterHandler); currentPointerData.hovered.Add(transform.gameObject); } }