Пример #1
0
        /// <summary>
        /// Called if the GameEventListener Container already exist
        /// </summary>
        /// <param name="gameEventListenersContainer">The GameObject containing the listeners</param>
        /// <param name="ListenersDictionary">The Listeners Dictionnary to modify</param>
        /// <param name="inputType">click or over</param>
        /// <returns>The Listeners Dictionnary with updated values</returns>
        public Dictionary <string, GameEventListenerTransform> SetListenerToPresentComponent(GameObject gameEventListenersContainer, Dictionary <string, GameEventListenerTransform> ListenersDictionary, EUIInputType inputType)
        {
            foreach (GameEventListenerTransform l in gameEventListenersContainer.GetComponents <GameEventListenerTransform>())
            {
                string eventName = l.GetEvent().name.ToLower();

                if (eventName.Contains(inputType.ToString().ToLower()))
                {
                    if (eventName.Contains("right"))
                    {
                        ListenersDictionary["Right"] = l;
                    }

                    else if (eventName.Contains("left"))
                    {
                        ListenersDictionary["Left"] = l;
                    }

                    else if (eventName.Contains("gaze"))
                    {
                        ListenersDictionary["Gaze"] = l;
                    }

                    else
                    {
                        Debug.LogError("Couldn't find the GameEventListenerTransform that correspond");
                    }
                }
            }
            return(ListenersDictionary);
        }
Пример #2
0
        // EMPTY
        #region PUBLIC_VARIABLES
        #endregion


        // EMPTY
        #region PRIVATE_VARIABLES
        #endregion


        #region PUBLIC_METHODS
        /// <summary>
        /// Check if the button gameobject contain a child named GameEventListenersButton
        /// </summary>
        /// <param name="gameEventListenersContainer">The GameObject containing the listeners</param>
        /// <param name="ListenersDictionary">The Dictionary of Listeners to feed, here only for the clicks</param>
        /// <param name="t">The Transform of the UI Element</param>
        /// <returns>return false if there's no child named GameEventListenersButton</returns>
        public bool CheckGameEventListenerChild(ref GameObject gameEventListenersContainer, ref Dictionary <string, GameEventListenerTransform> ListenersDictionary, Transform t, EUIInputType inputType)
        {
            for (int i = 0; i < t.childCount; i++)
            {
                if (t.GetChild(i).name.Contains("GameEventListeners"))
                {
                    gameEventListenersContainer = t.GetChild(i).gameObject;
                    ListenersDictionary         = SetListenerToPresentComponent(gameEventListenersContainer, ListenersDictionary, inputType);
                    return(true);
                }
            }
            return(false);
        }