Skip to content

Commit b87f4b3

Browse files
committed
Fix drawing FormattedNumber for multiple different values; minor refactor changes
1 parent 688f421 commit b87f4b3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Assets/Editor Toolbox/Editor/Drawers/Regular/FormattedNumberAttributeDrawer.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public class FormattedNumberAttributeDrawer : PropertyDrawerBase
1818
CurrencyDecimalSeparator = "."
1919
};
2020

21-
2221
private void ApplyControlName(string propertyKey)
2322
{
2423
GUI.SetNextControlName(propertyKey);
@@ -42,7 +41,6 @@ private string GetFormat(SerializedProperty property, FormattedNumberAttribute a
4241
return string.Format("{0}{1}", attribute.Format, isInt ? 0 : attribute.DecimalsToShow);
4342
}
4443

45-
4644
protected override void OnGUISafe(Rect position, SerializedProperty property, GUIContent label)
4745
{
4846
var key = property.GetPropertyHashKey();
@@ -62,6 +60,11 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU
6260
#endif
6361
}
6462

63+
if (property.hasMultipleDifferentValues)
64+
{
65+
return;
66+
}
67+
6568
var targetAttribute = attribute as FormattedNumberAttribute;
6669
var single = GetSingle(property);
6770
var format = GetFormat(property, targetAttribute);
@@ -79,7 +82,6 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU
7982
}
8083
}
8184

82-
8385
public override bool IsPropertyValid(SerializedProperty property)
8486
{
8587
return property.propertyType == SerializedPropertyType.Integer ||

Assets/Editor Toolbox/Editor/Utilities/PropertyUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ public static void OverrideLabelByValue(GUIContent label, SerializedProperty pro
421421
label.text = property.colorValue.ToString();
422422
break;
423423
case SerializedPropertyType.ObjectReference:
424-
label.text = property.objectReferenceValue ? property.objectReferenceValue.name : "null";
424+
label.text = property.objectReferenceValue ? property.objectReferenceValue.ToString() : "null";
425425
break;
426426
case SerializedPropertyType.LayerMask:
427427
switch (property.intValue)

0 commit comments

Comments
 (0)