Example #1
0
    /// <summary>
    /// Raise focus enter and exit events for when an input (that supports pointing) points to a game object.
    /// </summary>
    /// <param name="pointer"></param>
    /// <param name="oldFocusedObject"></param>
    /// <param name="newFocusedObject"></param>
    public void RaisePointerSpecificFocusChangedEvents(IPointingSource pointer, GameObject oldFocusedObject, GameObject newFocusedObject)
    {
        if (oldFocusedObject != null)
        {
            pointerSpecificEventData.Initialize(pointer);
            ExecuteEvents.ExecuteHierarchy(oldFocusedObject, pointerSpecificEventData, OnPointerSpecificFocusExitEventHandler);
        }

        if (newFocusedObject != null)
        {
            pointerSpecificEventData.Initialize(pointer);
            ExecuteEvents.ExecuteHierarchy(newFocusedObject, pointerSpecificEventData, OnPointerSpecificFocusEnterEventHandler);
        }
    }
Example #2
0
        /// <summary>
        /// Handle the pointer specific changes to fire focus enter and exit events
        /// </summary>
        /// <param name="pointer">The pointer associated with this focus change.</param>
        /// <param name="oldFocusedObject">Object that was previously being focused.</param>
        /// <param name="newFocusedObject">New object being focused.</param>
        private void OnPointerSpecificFocusChanged(IPointingSource pointer, GameObject oldFocusedObject, GameObject newFocusedObject)
        {
            PointerSpecificEventData eventData = new PointerSpecificEventData(EventSystem.current);

            eventData.Initialize(pointer);

            if (newFocusedObject != null && Isinteractable(newFocusedObject))
            {
                FocusEnter(newFocusedObject, eventData);
            }

            if (oldFocusedObject != null && Isinteractable(oldFocusedObject))
            {
                FocusExit(oldFocusedObject, eventData);
            }
        }