public override void OnInspectorGUI() { InitializeStyles(); if (AssetDatabase.Contains(_executive)) { var path = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(_executive))); GUI.Label(new Rect(44f, 24f, Mathf.Max(0f, Screen.width - 64f), EditorStyles.label.CalcHeight(new GUIContent("M"), 1920f)), path, EditorStyles.boldLabel); } GUIExtensions.ResetEnable(); GUIExtensions.PushEnable(!_executive.isGenerating); EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins); bool canGenerate = _executive.canGenerate; GUIExtensions.PushEnable(canGenerate); if (GUILayout.Button("Generate", _generateButtonStyle)) { _executive.Generate(); } GUIExtensions.PopEnable(); if (!canGenerate) { var priorBackgroundColor = GUI.backgroundColor; int count = 0; bool showMore = false; foreach (var generator in _executive.generators) { var message = generator.canGenerateMessage; if (!string.IsNullOrEmpty(message)) { if (count == 0) { GUILayout.Space(_sectionEndSpaceHeight / 2); GUI.backgroundColor = Color.Lerp(GUI.color, Color.red, 0.5f); EditorGUILayout.BeginVertical(_messageBoxStyle); } else if (count == 1) { _messageFoldoutAnimation.target = _messageFoldout; showMore = EditorGUILayout.BeginFadeGroup(_messageFoldoutAnimation.faded); } if (count == 0 || showMore) { EditorGUILayout.LabelField(new GUIContent(string.Format("{0}: {1}", generator.name, message)), _messageStyle); } ++count; } } if (count > 0) { if (count > 1) { EditorGUILayout.EndFadeGroup(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.Space(); if (GUILayout.Button(new GUIContent(_messageFoldout ? "hide" : "more..."), _messageMoreHideButtonStyle, GUILayout.ExpandWidth(false))) { _messageFoldout = !_messageFoldout; } var rect = GUILayoutUtility.GetLastRect(); GUI.Label(rect, new GUIContent("________________"), _messageMoreHideButtonStyle); EditorGUILayout.Space(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); GUI.backgroundColor = priorBackgroundColor; } } GUILayout.Space(_sectionEndSpaceHeight / 2); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button(new GUIContent("Detach Assets", "Disassociate all assets from this generator."))) { if (EditorUtility.DisplayDialog("Detach Assets", "This will disassociate all assets from this generator, which means that these assets will no longer be automatically destroyed or replaced by future executions of the generator.\n\nIt is recommended that you move these assets to another location before you execute the generator again, so that they do not conflict with newly generated assets.", "OK", "Cancel")) { _executive.DetachAssets(); } } if (GUILayout.Button(new GUIContent("Delete Assets", "Delete all assets generated by this generator."))) { if (EditorUtility.DisplayDialog("Delete Assets", "This will delete all assets generated by and still associated with this generator.\n\nAre you sure you want to proceed?", "OK", "Cancel")) { _executive.DeleteAssets(); } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); GUILayout.Space(_sectionEndSpaceHeight); foreach (var generator in _executive.generators) { GeneratorEditorState editorState; if (!_editorStates.TryGetValue(generator, out editorState)) { editorState = new GeneratorEditorState(); editorState.editor = CreateEditor(generator); editorState.foldout = true; editorState.foldoutAnimation = new AnimBool(editorState.foldout); editorState.foldoutAnimation.valueChanged.AddListener(Repaint); _editorStates[generator] = editorState; } GUILayout.BeginHorizontal(_generatorHeaderStyle); GUILayout.BeginVertical(); GUILayout.Space(1f); GUILayout.Label(generator.name, _generatorHeaderLabelStyle, GUILayout.ExpandWidth(true)); GUILayout.EndVertical(); if (GUILayout.Button(GUIContent.none, _generatorHeaderMenuButtonStyle)) { ShowGeneratorMenu(generator, _editorStates[generator]._menuButtonRect); } if (Event.current.type == EventType.Repaint) { _editorStates[generator]._menuButtonRect = GUILayoutUtility.GetLastRect(); } GUILayout.EndHorizontal(); var rect = GUILayoutUtility.GetLastRect(); rect.xMin += EditorStyles.foldout.padding.left; rect.yMin += 3; rect.yMax = rect.yMin + EditorStyles.foldout.CalcHeight(new GUIContent("M"), 1920f); editorState.foldout = EditorGUI.Foldout(rect, editorState.foldout, GUIContent.none); editorState.foldoutAnimation.target = editorState.foldout; if (EditorGUILayout.BeginFadeGroup(editorState.foldoutAnimation.faded)) { EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins); editorState.editor.OnInspectorGUI(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); } EditorGUILayout.EndFadeGroup(); } Separator(); GUILayout.Space(_sectionEndSpaceHeight); OnAddGeneratorButtonGUI(); GUIExtensions.PopEnable(); }