public override void OnGUI(string searchContext) { if (m_SettingsEditor != null) { using (new EditorGUI.DisabledScope(!m_SettingsEditor.IsEnabled())) { using (new SettingsWindow.GUIScope()) m_SettingsEditor.OnInspectorGUI(); // Emulate the Inspector by handling DnD at the native level. var remainingRect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true)); if ((Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform) && remainingRect.Contains(Event.current.mousePosition)) { DragAndDrop.visualMode = InternalEditorUtility.InspectorWindowDrag(new[] { m_SettingsEditor.target }, Event.current.type == EventType.DragPerform); if (Event.current.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); } } } } base.OnGUI(searchContext); }
internal static Rect DrawHeaderGUI(Editor editor, string header, float leftMargin) { if (Editor.s_Styles == null) { Editor.s_Styles = new Editor.Styles(); } GUILayout.BeginHorizontal(Editor.s_Styles.inspectorBig, new GUILayoutOption[0]); GUILayout.Space(38f); GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.Space(19f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); if (leftMargin > 0f) { GUILayout.Space(leftMargin); } if (editor) { editor.OnHeaderControlsGUI(); } else { EditorGUILayout.GetControlRect(new GUILayoutOption[0]); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); Rect lastRect = GUILayoutUtility.GetLastRect(); Rect r = new Rect(lastRect.x + leftMargin, lastRect.y, lastRect.width - leftMargin, lastRect.height); Rect rect = new Rect(r.x + 6f, r.y + 6f, 32f, 32f); if (editor) { editor.OnHeaderIconGUI(rect); } else { GUI.Label(rect, AssetPreview.GetMiniTypeThumbnail(typeof(UnityEngine.Object)), Editor.s_Styles.centerStyle); } Rect rect2 = new Rect(r.x + 44f, r.y + 6f, r.width - 44f - 38f - 4f, 16f); if (editor) { editor.OnHeaderTitleGUI(rect2, header); } else { GUI.Label(rect2, header, EditorStyles.largeLabel); } if (editor) { editor.DrawHeaderHelpAndSettingsGUI(r); } Event current = Event.current; if (editor != null && !editor.IsEnabled() && current.type == EventType.MouseDown && current.button == 1 && r.Contains(current.mousePosition)) { EditorUtility.DisplayObjectContextMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), editor.targets, 0); current.Use(); } return(lastRect); }
private void DrawEditor(Editor editor, int editorIndex, bool forceDirty, ref bool showImportedObjectBarNext, ref Rect importedObjectBarRect, bool eyeDropperDirty) { if (editor == null) { return; } UnityEngine.Object target = editor.target; GUIUtility.GetControlID(target.GetInstanceID(), FocusType.Passive); EditorGUIUtility.ResetGUIState(); GUILayoutGroup topLevel = GUILayoutUtility.current.topLevel; int visible = this.m_Tracker.GetVisible(editorIndex); bool flag; if (visible == -1) { flag = InternalEditorUtility.GetIsInspectorExpanded(target); this.m_Tracker.SetVisible(editorIndex, (!flag) ? 0 : 1); } else { flag = (visible == 1); } bool flag2 = forceDirty || editor.isInspectorDirty || eyeDropperDirty || InspectorWindow.s_FlushOptimizedGUI; if (Event.current.type == EventType.Repaint) { editor.isInspectorDirty = false; } ScriptAttributeUtility.propertyHandlerCache = editor.propertyHandlerCache; bool flag3 = AssetDatabase.IsMainAsset(target) || AssetDatabase.IsSubAsset(target) || editorIndex == 0 || target is Material; if (flag3) { string empty = string.Empty; bool flag4 = editor.IsOpenForEdit(out empty); if (showImportedObjectBarNext) { showImportedObjectBarNext = false; GUILayout.Space(15f); importedObjectBarRect = GUILayoutUtility.GetRect(16f, 16f); importedObjectBarRect.height = 17f; } flag = true; EditorGUI.BeginDisabledGroup(!flag4); editor.DrawHeader(); EditorGUI.EndDisabledGroup(); } if (editor.target is AssetImporter) { showImportedObjectBarNext = true; } bool flag5 = false; if (editor is GenericInspector && CustomEditorAttributes.FindCustomEditorType(target, false) != null) { if (this.m_InspectorMode != InspectorMode.DebugInternal) { if (this.m_InspectorMode == InspectorMode.Normal) { flag5 = true; } else { if (target is AssetImporter) { flag5 = true; } } } } if (!flag3) { EditorGUI.BeginDisabledGroup(!editor.IsEnabled()); bool flag6 = EditorGUILayout.InspectorTitlebar(flag, editor.targets); if (flag != flag6) { this.m_Tracker.SetVisible(editorIndex, (!flag6) ? 0 : 1); InternalEditorUtility.SetIsInspectorExpanded(target, flag6); if (flag6) { this.m_LastInteractedEditor = editor; } else { if (this.m_LastInteractedEditor == editor) { this.m_LastInteractedEditor = null; } } } EditorGUI.EndDisabledGroup(); } if (flag5 && flag) { GUILayout.Label("Multi-object editing not supported.", EditorStyles.helpBox, new GUILayoutOption[0]); return; } EditorGUIUtility.ResetGUIState(); EditorGUI.BeginDisabledGroup(!editor.IsEnabled()); GenericInspector genericInspector = editor as GenericInspector; if (genericInspector) { genericInspector.m_InspectorMode = this.m_InspectorMode; } EditorGUIUtility.hierarchyMode = true; EditorGUIUtility.wideMode = (base.position.width > 330f); ScriptAttributeUtility.propertyHandlerCache = editor.propertyHandlerCache; Rect rect = default(Rect); OptimizedGUIBlock optimizedGUIBlock; float num; if (editor.GetOptimizedGUIBlock(flag2, flag, out optimizedGUIBlock, out num)) { rect = GUILayoutUtility.GetRect(0f, (!flag) ? 0f : num); this.HandleLastInteractedEditor(rect, editor); if (Event.current.type == EventType.Layout) { return; } if (optimizedGUIBlock.Begin(flag2, rect) && flag) { GUI.changed = false; editor.OnOptimizedInspectorGUI(rect); } optimizedGUIBlock.End(); } else { if (flag) { GUIStyle style = (!editor.UseDefaultMargins()) ? GUIStyle.none : EditorStyles.inspectorDefaultMargins; rect = EditorGUILayout.BeginVertical(style, new GUILayoutOption[0]); this.HandleLastInteractedEditor(rect, editor); GUI.changed = false; try { editor.OnInspectorGUI(); } catch (Exception ex) { if (ex is ExitGUIException) { throw; } Debug.LogException(ex); } EditorGUILayout.EndVertical(); } if (Event.current.type == EventType.Used) { return; } } EditorGUI.EndDisabledGroup(); if (GUILayoutUtility.current.topLevel != topLevel) { if (!GUILayoutUtility.current.layoutGroups.Contains(topLevel)) { Debug.LogError("Expected top level layout group missing! Too many GUILayout.EndScrollView/EndVertical/EndHorizontal?"); GUIUtility.ExitGUI(); } else { Debug.LogWarning("Unexpected top level layout group! Missing GUILayout.EndScrollView/EndVertical/EndHorizontal?"); while (GUILayoutUtility.current.topLevel != topLevel) { GUILayoutUtility.EndLayoutGroup(); } } } this.HandleComponentScreenshot(rect, editor); }
internal static Rect DrawHeaderGUI(Editor editor, string header, float leftMargin) { if (Editor.s_Styles == null) { Editor.s_Styles = new Editor.Styles(); } GUILayout.BeginHorizontal(Editor.s_Styles.inspectorBig, new GUILayoutOption[0]); GUILayout.Space(38f); GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.Space(19f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); if (leftMargin > 0f) { GUILayout.Space(leftMargin); } if (editor) { editor.OnHeaderControlsGUI(); } else { EditorGUILayout.GetControlRect(new GUILayoutOption[0]); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); Rect lastRect = GUILayoutUtility.GetLastRect(); Rect r = new Rect(lastRect.x + leftMargin, lastRect.y, lastRect.width - leftMargin, lastRect.height); Rect rect = new Rect(r.x + 6f, r.y + 6f, 32f, 32f); if (editor) { editor.OnHeaderIconGUI(rect); } else { GUI.Label(rect, AssetPreview.GetMiniTypeThumbnail(typeof(UnityEngine.Object)), Editor.s_Styles.centerStyle); } Rect rect2 = new Rect(r.x + 44f, r.y + 6f, r.width - 44f - 38f - 4f, 16f); if (editor) { editor.OnHeaderTitleGUI(rect2, header); } else { GUI.Label(rect2, header, EditorStyles.largeLabel); } if (editor) { editor.DrawHeaderHelpAndSettingsGUI(r); } Event current = Event.current; if (editor != null && !editor.IsEnabled() && current.type == EventType.MouseDown && current.button == 1 && r.Contains(current.mousePosition)) { EditorUtility.DisplayObjectContextMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), editor.targets, 0); current.Use(); } return lastRect; }
private void DrawEditor(Editor editor, int editorIndex, bool rebuildOptimizedGUIBlock, ref bool showImportedObjectBarNext, ref Rect importedObjectBarRect) { if ((UnityEngine.Object) editor == (UnityEngine.Object) null) return; UnityEngine.Object target = editor.target; GUIUtility.GetControlID(target.GetInstanceID(), FocusType.Passive); EditorGUIUtility.ResetGUIState(); GUILayoutGroup topLevel = GUILayoutUtility.current.topLevel; int visible = this.m_Tracker.GetVisible(editorIndex); bool flag1; if (visible == -1) { flag1 = InternalEditorUtility.GetIsInspectorExpanded(target); this.m_Tracker.SetVisible(editorIndex, !flag1 ? 0 : 1); } else flag1 = visible == 1; rebuildOptimizedGUIBlock |= editor.isInspectorDirty; if (Event.current.type == EventType.Repaint) editor.isInspectorDirty = false; ScriptAttributeUtility.propertyHandlerCache = editor.propertyHandlerCache; bool flag2 = AssetDatabase.IsMainAsset(target) || AssetDatabase.IsSubAsset(target) || editorIndex == 0 || target is Material; if (flag2) { string message = string.Empty; bool flag3 = editor.IsOpenForEdit(out message); if (showImportedObjectBarNext) { showImportedObjectBarNext = false; GUILayout.Space(15f); importedObjectBarRect = GUILayoutUtility.GetRect(16f, 16f); importedObjectBarRect.height = 17f; } flag1 = true; EditorGUI.BeginDisabledGroup(!flag3); editor.DrawHeader(); EditorGUI.EndDisabledGroup(); } if (editor.target is AssetImporter) showImportedObjectBarNext = true; bool flag4 = false; if (editor is GenericInspector && CustomEditorAttributes.FindCustomEditorType(target, false) != null && this.m_InspectorMode != InspectorMode.DebugInternal) { if (this.m_InspectorMode == InspectorMode.Normal) flag4 = true; else if (target is AssetImporter) flag4 = true; } if (!flag2) { EditorGUI.BeginDisabledGroup(!editor.IsEnabled()); bool isExpanded = EditorGUILayout.InspectorTitlebar(flag1, editor.targets, editor.CanBeExpandedViaAFoldout()); if (flag1 != isExpanded) { this.m_Tracker.SetVisible(editorIndex, !isExpanded ? 0 : 1); InternalEditorUtility.SetIsInspectorExpanded(target, isExpanded); if (isExpanded) this.m_LastInteractedEditor = editor; else if ((UnityEngine.Object) this.m_LastInteractedEditor == (UnityEngine.Object) editor) this.m_LastInteractedEditor = (Editor) null; } EditorGUI.EndDisabledGroup(); } if (flag4 && flag1) { GUILayout.Label("Multi-object editing not supported.", EditorStyles.helpBox, new GUILayoutOption[0]); } else { EditorGUIUtility.ResetGUIState(); EditorGUI.BeginDisabledGroup(!editor.IsEnabled()); GenericInspector genericInspector = editor as GenericInspector; if ((bool) ((UnityEngine.Object) genericInspector)) genericInspector.m_InspectorMode = this.m_InspectorMode; EditorGUIUtility.hierarchyMode = true; EditorGUIUtility.wideMode = (double) this.position.width > 330.0; ScriptAttributeUtility.propertyHandlerCache = editor.propertyHandlerCache; Rect rect = new Rect(); OptimizedGUIBlock block; float height; if (editor.GetOptimizedGUIBlock(rebuildOptimizedGUIBlock, flag1, out block, out height)) { rect = GUILayoutUtility.GetRect(0.0f, !flag1 ? 0.0f : height); this.HandleLastInteractedEditor(rect, editor); if (Event.current.type == EventType.Layout) return; if (block.Begin(rebuildOptimizedGUIBlock, rect) && flag1) { GUI.changed = false; editor.OnOptimizedInspectorGUI(rect); } block.End(); } else { if (flag1) { rect = EditorGUILayout.BeginVertical(!editor.UseDefaultMargins() ? GUIStyle.none : EditorStyles.inspectorDefaultMargins, new GUILayoutOption[0]); this.HandleLastInteractedEditor(rect, editor); GUI.changed = false; try { editor.OnInspectorGUI(); } catch (Exception ex) { if (ex is ExitGUIException) throw; else Debug.LogException(ex); } EditorGUILayout.EndVertical(); } if (Event.current.type == EventType.Used) return; } EditorGUI.EndDisabledGroup(); if (GUILayoutUtility.current.topLevel != topLevel) { if (!GUILayoutUtility.current.layoutGroups.Contains((object) topLevel)) { Debug.LogError((object) "Expected top level layout group missing! Too many GUILayout.EndScrollView/EndVertical/EndHorizontal?"); GUIUtility.ExitGUI(); } else { Debug.LogWarning((object) "Unexpected top level layout group! Missing GUILayout.EndScrollView/EndVertical/EndHorizontal?"); while (GUILayoutUtility.current.topLevel != topLevel) GUILayoutUtility.EndLayoutGroup(); } } this.HandleComponentScreenshot(rect, editor); } }