示例#1
0
        // Start is called before the first frame update
        void Start()
        {
#if RUDDER
            // recover values presence detector when this script is reloaded
            show = RudderPedals.PresenceDetector.Instance.isPaused;
            switchScenePressed = RudderPedals.PresenceDetector.Instance.isPaused;

            // buttons init
            switchScene.OnTouchEnter((t) =>
            {
                //Debug.Log($"switch Scene {switchScenePressed}");
                //if (switchScenePressed) return;
                if (Time.time - StateManager.Instance.lastSwitch < minSwitchWait)
                {
                    Debug.Log($"Attempted to switch scenes but button interaction was too early by {minSwitchWait - Time.time + StateManager.Instance.lastSwitch}s");
                    return;
                }

                switchScenePressed = true;
                switch (StateManager.Instance.currentState)
                {
                case StateManager.States.Training:
                    Debug.Log("Changing scene to HUD");
                    StateManager.Instance.GoToState(StateManager.States.HUD, () =>
                    {
                        oldWheelchairVisibility = WheelchairStateManager.Instance.visible;
                        WheelchairStateManager.Instance.SetVisibility(true,
                                                                      StateManager.Instance.currentState == StateManager.States.HUD ? WheelchairStateManager.HUDAlpha : 1);
                    });
                    break;

                case StateManager.States.HUD:
                    Debug.Log("Changing scene to Traning");
                    StateManager.Instance.GoToState(StateManager.States.Training);
                    break;
                }
            });
#else
            switchScene.gameObject.SetActive(false);
            transform.gameObject.SetActive(false);
#endif
        }