예제 #1
0
        IEnumerator Init()
        {
#pragma warning disable 168
            // Ensure the global comp root is initialized so that it doesn't get parented to us below
            var globalRoot = GlobalCompositionRoot.Instance;
#pragma warning restore 168

            _beforeInstallHooks = SceneCompositionRoot.BeforeInstallHooks;
            SceneCompositionRoot.BeforeInstallHooks = null;

            _afterInstallHooks = SceneCompositionRoot.AfterInstallHooks;
            SceneCompositionRoot.AfterInstallHooks = null;

            var rootObjectsBeforeLoad = UnityUtil.GetRootGameObjects();

            ZenUtil.LoadSceneAdditive(
                SceneName, AddPreBindings, AddPostBindings);

            // Wait one frame for objects to be added to the scene heirarchy
            yield return(null);

            var newlyAddedObjects = UnityUtil.GetRootGameObjects().Except(rootObjectsBeforeLoad);

            foreach (var obj in newlyAddedObjects)
            {
                obj.transform.SetParent(this.transform);
            }
        }
        public void Awake()
        {
            // We always want to initialize GlobalCompositionRoot as early as possible
            GlobalCompositionRoot.Instance.EnsureIsInitialized();

            _beforeInstallHooks = SceneCompositionRoot.BeforeInstallHooks;
            SceneCompositionRoot.BeforeInstallHooks = null;

            _afterInstallHooks = SceneCompositionRoot.AfterInstallHooks;
            SceneCompositionRoot.AfterInstallHooks = null;

            SceneCompositionRoot.DecoratedScenes.Add(this.gameObject.scene);

            ZenUtil.LoadSceneAdditive(
                SceneName, AddPreBindings, AddPostBindings);
        }
        public void Awake()
        {
#pragma warning disable 168
            // Ensure the global comp root is initialized so that it doesn't get parented to us below
            var globalRoot = GlobalCompositionRoot.Instance;
#pragma warning restore 168

            _beforeInstallHooks = SceneCompositionRoot.BeforeInstallHooks;
            SceneCompositionRoot.BeforeInstallHooks = null;

            _afterInstallHooks = SceneCompositionRoot.AfterInstallHooks;
            SceneCompositionRoot.AfterInstallHooks = null;

            ZenUtil.LoadSceneAdditive(
                SceneName, AddPreBindings, AddPostBindings);
        }