public static IEnumerable <ZenjectResolveException> ValidateInstallers(CompositionRoot compRoot) { var globalContainer = GlobalCompositionRoot.CreateContainer(true, null); var container = compRoot.CreateContainer(true, globalContainer); foreach (var error in container.ValidateResolve <IDependencyRoot>()) { yield return(error); } // Also make sure we can fill in all the dependencies in the built-in scene foreach (var curTransform in compRoot.GetComponentsInChildren <Transform>()) { foreach (var monoBehaviour in curTransform.GetComponents <MonoBehaviour>()) { if (monoBehaviour == null) { Log.Warn("Found null MonoBehaviour on " + curTransform.name); continue; } foreach (var error in container.ValidateObjectGraph(monoBehaviour.GetType())) { yield return(error); } } } foreach (var installer in globalContainer.InstalledInstallers.Concat(container.InstalledInstallers)) { if (installer is IValidatable) { foreach (var error in ((IValidatable)installer).Validate()) { yield return(error); } } } foreach (var error in container.ValidateValidatables()) { yield return(error); } }
// If we're destroyed manually somehow handle that public void OnDestroy() { _instance = null; _dependencyRoot = null; }