コード例 #1
0
    private void Start()
    {
        // This assigns the gameObject instances to their respected gameObjects. (ZMS)
        ground             = GameObject.FindWithTag("GroundFloorTag");
        buttonBackground   = GameObject.FindWithTag("ButtonBackgroundTag");
        backToLobby        = GameObject.FindWithTag("JumbBackToLobbyTag").GetComponent <Button>();
        laserPointerObject = GameObject.FindWithTag("LaserPointerTag");

        if (Instance)
        {
            Debug.LogWarning("A second Main script has been created while another exists! This instance will not be saved!");
        }
        else
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }

        Bindings._left_handed = leftHanded;

        VRMain.Instance.AddEventGenerator(this);

        VRMain.Instance.AddOnVRAnalogUpdateCallback(_potentiometer, OnSliderAnalogUpdate);

        VRMain.Instance.AddVRButtonCallbacks(_front_button, OnFrontButtonUp, OnFrontButtonDown);
        VRMain.Instance.AddVRButtonCallbacks(_back_button, OnBackButtonUp, OnBackButtonDown);

        VRMain.Instance.vrDevice.unityKeysToVREvents.Add(Bindings._scene_advance_key);

        Bindings.AddSceneAdvanceCallback(OnSceneAdvance);

        Bindings.InitializeMinVRLayoutSwitching(server);

        Bindings.AddMinVRLayoutSwitchingHandlers(i => delegate { layoutManager.DropdownValueSelected(i); });

        Bindings.AddMinVRChallengeAndTrialCallbacks(SkipTrial, RestartTrial, SkipChallenge, RestartChallenge);

        outputDisplay?.ResetText();

        trials = Testing.Utils.ReadTrialsStaggered(logComments: false);

        RunNextTrial();

        // This section ensures that the stylus, the ground, and the start button art
        // not destroyed when the user/proctor switches between the Lobby and Trial
        // scenes. (ZMS)
        DontDestroyOnLoad(stylus.gameObject);
        DontDestroyOnLoad(ground.gameObject);
        DontDestroyOnLoad(buttonBackground.gameObject);
        DontDestroyOnLoad(backToLobby.gameObject);

        SceneManager.sceneLoaded += OnSceneChange;
    }