//----------------------------------------------------------------------

        #region Public Functions

        public void AddFocuser(AFocuser focuser)
        {
            if (!m_Focusers.Contains(focuser))
            {
                m_Focusers.Add(focuser);
            }
        }
        public static AFocuser GetFocuserForInputSource(InputSourceBase inputSource)
        {
            AFocuser focuser = null;

            if (FocusManager.Instance != null)
            {
                for (int index = 0; index < FocusManager.Instance.Focusers.Length; index++)
                {
                    InputSourceFocuser sourceFocuser = FocusManager.Instance.Focusers[index] as InputSourceFocuser;
                    if (sourceFocuser != null && sourceFocuser.m_InputSource == inputSource)
                    {
                        focuser = FocusManager.Instance.Focusers[index];
                        break;
                    }
                }

                //If we haven't found a specific focuser use the gaze.
                if (focuser == null)
                {
                    focuser = FocusManager.Instance.GazeFocuser;
                }
            }

            return(focuser);
        }
        private void UpdateFocusExit(AFocuser focuser)
        {
            FocusArgs arg = new FocusArgs();

            arg.Focuser = focuser;
            for (int index = 0; index < focuser.FocusExitList.Count; index++)
            {
                GameObject obj = focuser.FocusExitList[index];
                arg.CurNumFocusers = UpdateObjectCount(obj, -1);

                obj.SendMessage("FocusExit", arg, SendMessageOptions.DontRequireReceiver);
            }

            focuser.FocusExitList.Clear();
        }
        private void UpdateFocusList(AFocuser focuser)
        {
            for (int index = 0; index < focuser.FocusList.Count; index++)
            {
                GameObject obj = focuser.FocusList[index];
                if (!m_FocusedList.Contains(obj))
                {
                    m_FocusedList.Add(obj);
                }

                if (!focuser.FocusEnterList.Contains(obj))
                {
                    UpdateObjectCount(obj, 1);
                }
            }
        }
        //----------------------------------------------------------------------

        #region Private Functions

        /// <summary>
        /// Update the game object being focused on
        /// </summary>
        private void UpdateFocus()
        {
            m_PrevFocusedList.AddRange(m_FocusedList);
            m_FocusedList.Clear();

            for (int index = 0; index < m_Focusers.Length; index++)
            {
                AFocuser focuser = m_Focusers[index];
                if (focuser != null && focuser.CanInteract)
                {
                    this.UpdateFocusList(focuser);
                }
            }

            for (int index = 0; index < m_Focusers.Length; index++)
            {
                AFocuser focuser = m_Focusers[index];
                if (focuser != null && focuser.CanInteract)
                {
                    this.UpdateFocusEnter(focuser);
                }
            }

            for (int index = 0; index < m_Focusers.Length; index++)
            {
                AFocuser focuser = m_Focusers[index];
                if (focuser != null && focuser.CanInteract)
                {
                    this.UpdateFocusExit(focuser);
                }
            }

            FocusArgs args = new FocusArgs();

            for (int index = 0; index < m_Focusers.Length; index++)
            {
                AFocuser focuser = m_Focusers[index];
                if (focuser != null && focuser.CanInteract && focuser.PrimeFocus != focuser.OldPrimeFocus)
                {
                    args.Focuser = focuser;

                    if (focuser.OldUIInteractibleFocus != focuser.UIInteractibleFocus)
                    {
                        PointerEventData pointerEventData = focuser.GetPointerData();

                        ExecuteUIFocusEvent(focuser.OldUIInteractibleFocus, pointerEventData, ExecuteEvents.pointerExitHandler);
                        pointerEventData.pointerEnter = focuser.UIInteractibleFocus;
                        ExecuteUIFocusEvent(focuser.UIInteractibleFocus, pointerEventData, ExecuteEvents.pointerEnterHandler);
                    }

                    // Invoke events
                    if (OnFocusExit != null && focuser.OldPrimeFocus != null)
                    {
                        args.CurNumFocusers = m_ObjectFocusCount[focuser.OldPrimeFocus];
                        OnFocusExit(focuser.OldPrimeFocus, args);
                    }

                    if (OnFocusEnter != null && focuser.PrimeFocus != null)
                    {
                        args.CurNumFocusers = m_ObjectFocusCount[focuser.PrimeFocus];
                        OnFocusEnter(focuser.PrimeFocus, args);
                    }
                }
            }

            // Clean up
            m_ObjectFocusCount.Clear();

            m_PrevFocusedList.Clear();
        }
 public void RemoveFocuser(AFocuser focuser)
 {
     m_Focusers.Remove(focuser);
 }