Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Commit

Permalink
Properly restore label width (fixes issue 192).
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdufault committed Dec 4, 2016
1 parent 725f26a commit dd5b140
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Assets/FullInspector2/Core/Editor/IBehaviorEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public static T Edit<T>(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
Expand All @@ -92,7 +93,7 @@ public static T Edit<T>(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;
}
Expand Down

0 comments on commit dd5b140

Please sign in to comment.