From dd5b1401e329e3fa3aef96078720e3bc974e0688 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Sun, 4 Dec 2016 12:20:20 -0800 Subject: [PATCH] Properly restore label width (fixes issue 192). --- Assets/FullInspector2/Core/Editor/IBehaviorEditor.cs | 3 ++- Assets/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/FullInspector2/Core/Editor/IBehaviorEditor.cs b/Assets/FullInspector2/Core/Editor/IBehaviorEditor.cs index 4802310..8822c62 100644 --- a/Assets/FullInspector2/Core/Editor/IBehaviorEditor.cs +++ b/Assets/FullInspector2/Core/Editor/IBehaviorEditor.cs @@ -73,12 +73,13 @@ public void Edit(Rect rect, UnityObject behavior) { // Seed the label width - sometimes we don't always go through the // property editor logic. + float savedLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = fiGUI.PushLabelWidth(GUIContent.none, rect.width); // Run the editor OnEdit(rect, (TBehavior)behavior, fiPersistentMetadata.GetMetadataFor(behavior)); - fiGUI.PopLabelWidth(); + EditorGUIUtility.labelWidth = savedLabelWidth; // If the GUI has been changed, then we want to reserialize the // current object state. However, we don't bother doing this if we're diff --git a/Assets/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs b/Assets/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs index ca56ef5..8a43b4f 100644 --- a/Assets/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs +++ b/Assets/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs @@ -84,6 +84,7 @@ public static T Edit(this IPropertyEditor editor, Rect region, GUIContent lab BeginMethodSet(BaseMethodCall.Edit, out setBaseMethod); try { + float currentLabeWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = fiGUI.PushLabelWidth(label, region.width); // TODO: introduce a fast-path, we are burning lots of time in @@ -92,7 +93,7 @@ public static T Edit(this IPropertyEditor editor, Rect region, GUIContent lab if (typeof(T).IsPrimitive) result = DoEditFast(api, region, label, element, metadata.Metadata); else result = DoEditSlow(api, region, label, element, metadata.Metadata); - EditorGUIUtility.labelWidth = fiGUI.PopLabelWidth(); + EditorGUIUtility.labelWidth = currentLabeWidth; return result; }