예제 #1
0
    IEnumerator Loading(AsyncOperation progress, LoadingScreenBehaviour ls)
    {
        ls.Begin();
        LoadingState state = ls.state;

        while (!progress.isDone)
        {
            state.Callback("LoadingScene", progress.progress);
            yield return(null);
        }

        List <Action> doneListeners = new List <Action>();

        var initializer = GetInitializer();

        if (initializer != null)
        {
            state.Callback("InitializingScene", 0);
            yield return(null);

            AsyncProcessor processor = new AsyncProcessor(this);
            yield return(initializer.Initialize(processor, doneListeners.Add, state));

            yield return(new WaitUntil(processor.allDone));
        }

        ls.End();
        Done();
        foreach (var dl in doneListeners)
        {
            dl.Invoke();
        }
    }
예제 #2
0
        private void CreateLoadingScreen()
        {
            if (_loadingScreen != null)
            {
                return;
            }

            var go = ResourceLoader.LoadLoadingScreen();

            if (go == null)
            {
                Log.Error(MessageGroup.Gameplay, "Cant load loading screen prefab");
                return;
            }

            go = MainCanvasBehaviour.RegisterPanel(UIType.LoadingScreen, go);
            if (go == null)
            {
                return;
            }

            _loadingScreen = go.GetComponent <LoadingScreenBehaviour>();
            if (_loadingScreen == null)
            {
                Log.Error(MessageGroup.Gameplay, "Loading screen dont have behaviour");
            }

#if UNITY_EDITOR
            // Only for initialization of gameplay controller on first scene while testing.
            if (IsOnStage)
            {
                GameplayController.CreateGameplayControllerOnStageLoaded();
            }
#endif
        }