Beispiel #1
0
        private static IEnumerator WaitForSceneLoad(SceneRequest req, bool transitionOnSame)
        {
            var   currScene = SceneManager.GetActiveScene().name;
            float waitOut   = 0f;

            if (transitionOnSame || currScene != req.scene.sceneName)
            {
                var transition = req.scene.transitionIn == null ? defaultTransition : req.scene.transitionIn;
                CameraTransition.Fade(transition, out float waitIn, out waitOut);
                Log.Unity($"Performing fade transition for {waitIn}s before loading scene.");
                for (; waitIn > ETime.FRAME_YIELD; waitIn -= ETime.FRAME_TIME)
                {
                    yield return(null);
                }
            }
            Log.Unity($"Scene loading for {req} started.", level: Log.Level.DEBUG3);
            StaticPreSceneUnloaded();
            var op = SceneManager.LoadSceneAsync(req.scene.sceneName);

            while (!op.isDone)
            {
                yield return(null);
            }
            Log.Unity(
                $"Unity finished loading the new scene. Waiting for transition ({waitOut}s) before yielding control to player.",
                level: Log.Level.DEBUG3);
            req.onLoaded?.Invoke();
            for (; waitOut > ETime.FRAME_YIELD; waitOut -= ETime.FRAME_TIME)
            {
                yield return(null);
            }
            req.onFinished?.Invoke();
            EngineStateManager.SetLoading(false, () => LOADING = false);
        }
Beispiel #2
0
 private void Awake()
 {
     main = this;
     pb   = new MaterialPropertyBlock();
     sr   = GetComponent <SpriteRenderer>();
     if (inherited != null)
     {
         StartCoroutine(FadeOut(inherited));
         inherited = null;
     }
     else
     {
         Deactivate();
     }
 }