Ejemplo n.º 1
0
        void InstallBindings(List <MonoBehaviour> injectableMonoBehaviours)
        {
            if (_parentNewObjectsUnderContext)
            {
                _container.DefaultParent = transform;
            }
            else
            {
                _container.DefaultParent = null;
            }

            _container.Settings = _settings;

            _container.Bind <UniDiSceneLoader>().AsSingle();

            UniDiManagersInstaller.Install(_container);

            _container.Bind <Context>().FromInstance(this);

            _container.Bind(typeof(ProjectKernel), typeof(MonoKernel))
            .To <ProjectKernel>().FromNewComponentOn(gameObject).AsSingle().NonLazy();

            _container.Bind <SceneContextRegistry>().AsSingle();

            InstallSceneBindings(injectableMonoBehaviours);

            InstallInstallers();
        }
Ejemplo n.º 2
0
        protected virtual void Initialize()
        {
            Assert.IsNull(_container);

            _container = new DiContainer(new[] { StaticContext.Container });

            // Make sure we don't create any game objects since editor windows don't have a scene
            _container.AssertOnNewGameObjects = true;

            UniDiManagersInstaller.Install(_container);

            _container.Bind <Kernel>().AsSingle();
            _container.Bind <GuiRenderableManager>().AsSingle();
            _container.BindInstance(this);

            InstallBindings();

            _container.QueueForInject(this);
            _container.ResolveRoots();

            _kernel.Initialize();
        }