Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static IEnumerator LoadSceneAdditiveWithContainer(string levelName, DiContainer parentContainer)
- {
- var rootObjectsBeforeLoad = GameObject.FindObjectsOfType<Transform>().Where(x => x.parent == null).ToList();
- Application.LoadLevelAdditive(levelName);
- // Wait one frame for objects to be added to the scene heirarchy
- yield return null;
- var rootObjectsAfterLoad = GameObject.FindObjectsOfType<Transform>().Where(x => x.parent == null).ToList();
- foreach (var newObject in rootObjectsAfterLoad.Except(rootObjectsBeforeLoad).Select(x => x.gameObject))
- {
- Assert.That(newObject.GetComponent<CompositionRoot>() == null,
- "LoadSceneAdditiveWithContainer does not expect a container to exist in the loaded scene");
- InjectionHelper.InjectChildGameObjects(parentContainer, newObject);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement