コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        private void FixedUpdate()
        {
            if (InputHelper.AnyAxis(NextInputName) != 0.0f)
            {
                if (!_isNextPressed)
                {
                    ChangeGameMode(1);
                }
                _isNextPressed = true;
            }
            else
            {
                _isNextPressed = false;
            }

            if (InputHelper.AnyAxis(PrevInputName) != 0.0f)
            {
                if (!_isPrevPressed)
                {
                    ChangeGameMode(-1);
                }
                _isPrevPressed = true;
            }
            else
            {
                _isPrevPressed = false;
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        private void SettingsTabCycle()
        {
            if (InputHelper.AnyAxis(PrevInputName) != 0.0f || (isNavigatingTabs && InputHelper.GetAnyUIHorizontalAxis() < 0.0f))
            {
                if (!_isPrevPressed)
                {
                    _currentOptionIndex -= 1;
                    _currentOptionIndex  = MathExtensions.Mod(_currentOptionIndex, _optionIndex);
                    FocusChanged();
                }
                _isPrevPressed = true;
            }
            else
            {
                _isPrevPressed = false;
            }

            if (InputHelper.AnyAxis(NextInputName) != 0.0f || (isNavigatingTabs && InputHelper.GetAnyUIHorizontalAxis() > 0.0f))
            {
                if (!_isNextPressed)
                {
                    _currentOptionIndex += 1;
                    _currentOptionIndex  = MathExtensions.Mod(_currentOptionIndex, _optionIndex);
                    FocusChanged();
                }
                _isNextPressed = true;
            }
            else
            {
                _isNextPressed = false;
            }

            GameObject selectedPanel = null;

            _tabsToUnfocus.Clear();


            switch (_optionTexts[_currentOptionIndex])
            {
            case "Gameplay":
                _tabsToUnfocus.Add(_controlsPanel.GetComponent <SettingsTabUINavigation>());
                _tabsToUnfocus.Add(_videoPanel.GetComponent <SettingsTabUINavigation>());
                _tabsToUnfocus.Add(_audioPanel.GetComponent <SettingsTabUINavigation>());

                _gameplayPanel.SetActive(true);
                _controlsPanel.SetActive(false);
                _videoPanel.SetActive(false);
                _audioPanel.SetActive(false);

                selectedPanel = _gameplayPanel;
                break;

            case "Controls":
                _tabsToUnfocus.Add(_gameplayPanel.GetComponent <SettingsTabUINavigation>());
                _tabsToUnfocus.Add(_videoPanel.GetComponent <SettingsTabUINavigation>());
                _tabsToUnfocus.Add(_audioPanel.GetComponent <SettingsTabUINavigation>());

                _controlsPanel.SetActive(true);

                selectedPanel = _controlsPanel;
                break;

            case "Video":
                _tabsToUnfocus.Add(_gameplayPanel.GetComponent <SettingsTabUINavigation>());
                _tabsToUnfocus.Add(_controlsPanel.GetComponent <SettingsTabUINavigation>());
                _tabsToUnfocus.Add(_audioPanel.GetComponent <SettingsTabUINavigation>());

                _videoPanel.SetActive(true);

                selectedPanel = _videoPanel;
                break;

            case "Audio":
                _tabsToUnfocus.Add(_gameplayPanel.GetComponent <SettingsTabUINavigation>());
                _tabsToUnfocus.Add(_controlsPanel.GetComponent <SettingsTabUINavigation>());
                _tabsToUnfocus.Add(_videoPanel.GetComponent <SettingsTabUINavigation>());

                _audioPanel.SetActive(true);

                selectedPanel = _audioPanel;
                break;
            }

            foreach (var tabToUnfocus in _tabsToUnfocus)
            {
                if (tabToUnfocus != null)
                {
                    tabToUnfocus.Unfocus(true);
                    tabToUnfocus.gameObject.SetActive(false);
                }
            }

            var navigation = selectedPanel?.GetComponent <SettingsTabUINavigation>();

            if (navigation != null)
            {
                navigation.panelNavigationHandler = this;
                if (!isNavigatingTabs && !navigation.hasFocus)
                {
                    navigation.SetLastAxes(Vector2.one);
                    navigation.Focus();
                }
            }
        }