/* UNCOMMENT FOR ADDING SCENE TO EXISTING SCENE */
    //
    // Summary:
    //      Preforms the level loading based on the player entering a trigger area

    /*
     * void OnTriggerEnter(Collider other)
     * {
     *  // If the collided object is the player and the box hasn't been triggered before.
     *  if (other.gameObject.name == "Player" && !_HasBeenTriggered)
     *  {
     *      if (UnloadScene)
     *      {
     *          // Asynchronously unloads the selected scene.
     *          SceneManager.UnloadSceneAsync(SelectScene.ToString());
     *      }
     *      else
     *      {
     *          // A switch case. Not needed, but is important to know what it looks like.
     *          // You could just do StartCoroutine(LoadSceneAsync(LoadSceneMode.Additive));
     *          // and ignore the switch case entierly, but if you want to preform any special
     *          // commands based on the selected level, this is how you'd do it.
     *          switch (SelectScene)
     *          {
     *              case SceneSelection.Scene_1:
     *                  //Some unique action based on scene selection
     *                  // Load scene *into* existing scene.
     *                  StartCoroutine(LoadSceneAsync(LoadSceneMode.Additive));
     *                  // a break statement is required at the end of each case statement.
     *                  break;
     *              case SceneSelection.Scene_2:
     *                  //Some unique action based on scene selection
     *                  // Load scene *into* existing scene.
     *                  StartCoroutine(LoadSceneAsync(LoadSceneMode.Additive));
     *                  // a break statement is required at the end of each case statement.
     *                  break;
     *          }
     *      }
     *      // Updates the _HasBeenTriggered value to true, meaning the OnTriggerEnter can not
     *      // be triggered again.
     *      _HasBeenTriggered = true;
     *  }
     * }
     */
    //
    // Summary:
    //      Loads a scene asynconously. It will load a scene only once the scene fully loads.
    //
    // Parameters:
    //   lsm:
    //     The enum value of LoadSceneMode. Either LoadSceneMode.Additive or LoadSceneMode.Single.
    //
    // Returns:
    //     null
    IEnumerator LoadSceneAsync(LoadSceneMode lsm)
    {
        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(SelectScene.ToString(), lsm);

        // Wait until the asynchronous scene fully loads
        while (!asyncLoad.isDone)
        {
            yield return(null);
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.name == "Player")
        {
            SceneManager.LoadScene(SelectScene.ToString(), LoadSceneMode.Single);
            // LoadScene.Additive loads the scene onto the active scene
            //SceneManager.LoadScene(SelectScene.ToString(), LoadSceneMode.Additive);

            // An alternative to the basic SceneManager.LoadScene, you can load a scene
            // asynconously, meaning that the scene will only open once it has fully loaded.
            // StartCoroutine(LoadSceneAsync(LoadSceneMode.Single));
        }
    }
Exemplo n.º 3
0
        /// <summary>
        /// インデックスに応じた終了処理を行う
        /// </summary>
        private IEnumerator Enter()
        {
            // 音量を変更
            audioSource.volume = 0.25f;
            // 音源をセット
            audioSource.clip = submitClip;
            // 選択音の再生
            audioSource.Play();
            // 決定中のフラグをONにする
            isSubmit = true;
            // 音がなる時間を用意する
            yield return(StartCoroutine(WaitPlaySound()));

            // 前回の順位をリセット
            GameManager.Instance.playerResultInfos.Clear();
            // 選択したシーンに遷移
            SceneManager.LoadScene(selectScene.ToString());
        }