public static void OutputObjectGraphForScene() { if (!EditorApplication.isPlaying) { Log.Error("Zenject error: Must be in play mode to generate object graph. Hit Play button and try again."); return; } DiContainer container; try { container = ZenEditorUtil.GetContainerForCurrentScene(); } catch (ZenjectException e) { Log.Error("Unable to find container in current scene. " + e.Message); return; } var ignoreTypes = Enumerable.Empty <Type>(); var types = container.AllConcreteTypes; ZenEditorUtil.OutputObjectGraphForCurrentScene(container, ignoreTypes, types); }
static bool ValidateCompRoot(CompositionRoot compRoot, DateTime startTime) { if (compRoot.Installers.IsEmpty()) { Log.Warn("Could not find installers while validating current scene"); // Return true to allow playing in this case return(true); } // Only show a few to avoid spamming the log too much var resolveErrors = ZenEditorUtil.ValidateInstallers(compRoot).Take(10).ToList(); foreach (var error in resolveErrors) { Log.ErrorException(error); } var secondsElapsed = (DateTime.Now - startTime).Milliseconds / 1000.0f; if (resolveErrors.Any()) { Log.Error("Validation Completed With Errors, Took {0:0.00} Seconds.", secondsElapsed); return(false); } Log.Info("Validation Completed Successfully, Took {0:0.00} Seconds.", secondsElapsed); return(true); }
public static IEnumerable <ZenjectResolveException> ValidateCurrentScene() { var compRoot = GameObject.FindObjectsOfType <SceneCompositionRoot>().OnlyOrDefault(); if (compRoot == null || compRoot.Installers.IsEmpty()) { return(Enumerable.Empty <ZenjectResolveException>()); } return(ZenEditorUtil.ValidateInstallers(compRoot)); }
public override void OnInspectorGUI() { serializedObject.Update(); if (Application.isPlaying) { GUI.enabled = false; } GUILayout.Space(5); var binder = target as SceneDecoratorCompositionRoot; EditorGUILayout.BeginHorizontal(); { binder.SceneName = EditorGUILayout.TextField("Decorated Scene", binder.SceneName); GUILayout.Space(10); if (GUILayout.Button("Open", GUILayout.MaxWidth(40))) { EditorApplication.delayCall += () => { var scenePath = UnityEditorUtil.TryGetScenePath(binder.SceneName); if (scenePath == null) { EditorUtility.DisplayDialog("Error", "Could not find scene with name '{0}'. Is it added to your build settings?".Fmt(binder.SceneName), "Ok"); } else { #if UNITY_5_3 if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) #else if (EditorApplication.SaveCurrentSceneIfUserWantsTo()) #endif { ZenEditorUtil.OpenScene(scenePath); var compRoot = ZenEditorUtil.TryGetSceneCompositionRoot(); if (compRoot != null) { Selection.activeGameObject = compRoot.gameObject; } else { var decoratorCompRoot = ZenEditorUtil.TryGetSceneDecoratorCompositionRoot(); if (decoratorCompRoot != null) { Selection.activeGameObject = decoratorCompRoot.gameObject; } } } } }; } } EditorGUILayout.EndHorizontal(); foreach (var list in _propLists) { list.DoLayoutList(); } GUI.enabled = true; serializedObject.ApplyModifiedProperties(); }