Esempio n. 1
0
        private static IEnumerator LoadInternal(LoadContext context)
        {
            if (context == null)
            {
                yield break;
            }

            var scene = UnitySceneManager.GetSceneByName(context.NextScene.Name);

            if (!scene.isLoaded)
            {
                yield return(UnitySceneManager.LoadSceneAsync(context.NextScene.Name, LoadSceneMode.Additive));
            }
            UnitySceneManager.SetActiveScene(UnitySceneManager.GetSceneByName(context.NextScene.Name));

            var sceneContext = FindSceneContext(context.NextScene.Name);

            if (sceneContext == null)
            {
                yield break;
            }

            yield return(new WaitUntil(() => sceneContext.Initialized));

            var sceneSettings = sceneContext.Container.TryResolve <SceneSettings>();

            if (sceneSettings != null)
            {
                sceneSettings.Subs.ForEach(x => context.AddAdditiveScene(x));
            }
            context.NextScene.Lifecycles = sceneContext.Container.ResolveAll <ISceneLifecycle>();
        }