예제 #1
0
        private IEnumerator loadingCore(string sceneName)
        {
            // load core scene as an ADDITIVE SCENE
            asyncOperation = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
            asyncOperation.allowSceneActivation = false;

            // isDone will only return true
            // if the data is loaded AND the scene is active.
            while (!asyncOperation.isDone)
            {
                // track the progression of the loading here:
                // [0, 0.9] > [0, 1]

                if (asyncOperation.progress <= 0.9f)
                {
                    float progress = Mathf.Clamp01(asyncOperation.progress / 0.9f);
                    if (loadingBar != null)
                    {
                        loadingBar.transform.localScale = new Vector3(progress, barY, barZ);
                        percentage.text = Mathf.Round(progress * 100) + "%";
                    }
                }

                // Progress only returns values between 0 and 0.9;
                // 1 is only returned if the scene is ALSO active,
                // in which isDone is set to true

                if (asyncOperation.progress == 0.9f)
                {
                    // Loading completed...
                    yield return(StartCoroutine(canvasToFade.FadeIn()));

                    // Activate Scene
                    asyncOperation.allowSceneActivation = true;
                    Manager_LoadingScene.UnloadLoadingScene();
                }

                yield return(null);
            }

            //	canvasToFade = GameObject.FindGameObjectWithTag("FadingCanvas").GetComponent<CanvasFader>();
            if (canvasToFade != null)
            {
                // Fade-In Coroutine, (Black --> New Scene)
                yield return(StartCoroutine(canvasToFade.FadeOut()));

                canvasToFade.gameObject.SetActive(false);
            }

            if (sceneName != "MainMenu")
            {
                Manager_System.Instance.ShowFloorMenu();
            }

            Stop_LoadCoreScene();
        }
예제 #2
0
 private void Awake()
 {
     if (Instance == null)
     {
         // Ensure persistent presence accross scenes:
         DontDestroyOnLoad(this.gameObject);
         // Create Singelton instance:
         Instance = this;
     }
     else
     // if a manager already exists (check by calling the static variable),
     // and it's not this one (that we are attempting to create)...
     if (Instance != this)
     {
         //...then delete this one, we don't need two!
         Destroy(gameObject);
     }
 }