Exemplo n.º 1
0
        public void Awake()
        {
            isPassive = false;

            if (ButtonsSelected.Contains(null))
            {
                Debug.LogError("Buttons were not initialized on:" + this.gameObject.name + ". Please go to the object LoadScene" +
                               " component and select (or-reselect a button). ");
            }
        }
Exemplo n.º 2
0
        //// called first
        //void OnEnable()
        //{
        //    Debug.Log("OnEnable called");
        //    SceneManager.sceneLoaded += OnSceneLoaded;
        //}

        /// <summary>
        /// Register all the buttons on the control set.
        /// </summary>
        /// <param name="userSelectedButtons">The ButtonNames</param>
        /// <param name="userSelectedActions">The ButtonActions</param>
        public void RegisterButtons(Button.ButtonName[] userSelectedButtons, Button.ButtonActions[] userSelectedActions, bool[] positions)
        {
            if (ButtonsSelected == null)
            {
                ButtonsSelected = new List <ButtonRegistry>();
            }

            // Foreach userSelectedButton we add the button.
            for (int i = 0; i < userSelectedButtons.Length; i++)
            {
                ButtonRegistry reg = ScriptableObject.CreateInstance <ButtonRegistry>();
                reg.Name   = userSelectedButtons[i];
                reg.Action = userSelectedActions[i];
                reg.IsRightControllerButton = positions[i];
                reg.OverrideInteraction     = true;
                ButtonsSelected.Add(reg);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Given a ButtonName and a ButtonAction return the list of actions to perform.
        /// </summary>
        /// <param name="name">The ButtonName for to return the selected actions.</param>
        /// <param name="action">The ButtonAction for to return the selected actions.</param>
        /// <returns>A list of actions.</returns>
        public List <Action> GetButtonMethods(Button.ButtonName name, Button.ButtonActions action)
        {
            List <Action> returnActions = new List <Action>();

            if (ButtonsSelected == null)
            {
                Debug.LogError("No button selected.");
                return(null);
            }
            if (ButtonsSelected.Contains(null))
            {
                Debug.LogError("This object interaction: " + this.gameObject.name + " is not properly initialized! Maybe you copied its values." +
                               "Please go to it's game object inspector to update it automatically.");
            }

            // If this button is registered return the action.
            if (ButtonsSelected.Find(reg => reg.Name == name && reg.Action == action))
            {
                returnActions.Add(LoadAScene);
            }

            return(returnActions);
        }