private void Navigate(CustomInput.UserInput direction) { GameObject next = EventSystem.current.currentSelectedGameObject; if(next == null) { if(deck.GetDeck.Count > 0) { Transition(0); EventSystem.current.SetSelectedGameObject(selectionButtons[0].gameObject); } else { EventSystem.current.SetSelectedGameObject(okayButton.gameObject); } return; } bool nextIsValid = false; while (!nextIsValid) { switch(direction) { case CustomInput.UserInput.Up: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnUp().gameObject; break; case CustomInput.UserInput.Down: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnDown().gameObject; break; case CustomInput.UserInput.Left: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnLeft().gameObject; break; case CustomInput.UserInput.Right: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnRight().gameObject; break; } EventSystem.current.SetSelectedGameObject(next); nextIsValid = next.GetComponent<Selectable>().interactable; } }
void Awake() { if (instance == null) { DontDestroyOnLoad(this.gameObject); instance = this; } else if (this != instance) { Destroy(this.gameObject); return; } bools = new bool[System.Enum.GetNames(typeof(UserInput)).Length, 7]; boolsUp = new bool[System.Enum.GetNames(typeof(UserInput)).Length, 7]; boolsHeld = new bool[System.Enum.GetNames(typeof(UserInput)).Length, 7]; boolsFreshPress = new bool[System.Enum.GetNames(typeof(UserInput)).Length, 7]; boolsFreshPressAccessed = new bool[System.Enum.GetNames(typeof(UserInput)).Length, 7]; boolsFreshPressDeleteOnRead = new bool[System.Enum.GetNames(typeof(UserInput)).Length, 7]; raws = new float[System.Enum.GetNames(typeof(UserInput)).Length, 7]; rawsUp = new float[System.Enum.GetNames(typeof(UserInput)).Length, 7]; rawsHeld = new float[System.Enum.GetNames(typeof(UserInput)).Length, 7]; rawsFreshPress = new float[System.Enum.GetNames(typeof(UserInput)).Length, 7]; rawsFreshPressAccessed = new bool[System.Enum.GetNames(typeof(UserInput)).Length, 7]; rawsFreshPressDeleteOnRead = new float[System.Enum.GetNames(typeof(UserInput)).Length, 7]; keyboard = new KeyCode[System.Enum.GetNames(typeof(UserInput)).Length, 7]; gamepad = new string[System.Enum.GetNames(typeof(UserInput)).Length, 7]; rawSign = new int[System.Enum.GetNames(typeof(UserInput)).Length]; gamepadMapping = new Controller[7]; gamepadMapping[0].type = ControlType.Xbox; gamepadMapping[0].joysticNum = 0; RawSign(); if (UseConfigFile && FileExists()) Load(); else { Default(); Store(); } }
private void Navigate(CustomInput.UserInput direction) { GameObject next = EventSystem.current.currentSelectedGameObject; if (next == null) { EventSystem.current.SetSelectedGameObject(packs[0].gameObject); return; } bool nextIsValid = false; while (!nextIsValid) { switch (direction) { case CustomInput.UserInput.Up: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnUp().gameObject; break; case CustomInput.UserInput.Down: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnDown().gameObject; break; case CustomInput.UserInput.Left: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnLeft().gameObject; break; case CustomInput.UserInput.Right: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnRight().gameObject; break; } EventSystem.current.SetSelectedGameObject(next); nextIsValid = next.GetComponent<Selectable>().interactable; } }