示例#1
0
 private void InjectAllScenes()
 {
     for (int i = 0; i < SceneManager.sceneCount; i++)
     {
         var scene = SceneManager.GetSceneAt(i);
         if (scene.isLoaded)
         {
             _injector.Inject(scene);
         }
         else
         {
             Debug.LogWarningFormat(
                 "Not injecting dependencies to scene {0} as it's not loaded", scene.path);
         }
     }
 }
示例#2
0
        public IEnumerator InjectSuperclass()
        {
            var parent = new GameObject("parent");
            var obj    = new GameObject("main");

            obj.transform.SetParent(parent.transform);

            var component = obj.AddComponent <ReceiverSubclassComponent>();

            _injector.Inject(parent);

            Assert.AreSame(
                _fakeService,
                component.SuperService,
                "Injects dependency into child component's superclass field"
                );
            Assert.IsTrue(
                component.SuperMethodCalled,
                "Calls OnInject method on child component's superclass"
                );

            UnityEngine.Object.DestroyImmediate(parent);

            yield return(null);
        }