mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-22 08:08:51 -05:00
Fix bug where usage popup sometimes were hidden
This commit is contained in:
parent
b2a838a18f
commit
27959b9dd4
@ -53,17 +53,6 @@ namespace UnityAtoms.Editor
|
|||||||
|
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
var usage = property.FindPropertyRelative("_usage");
|
|
||||||
int usagePopupIndex = 0;
|
|
||||||
for (var i = 0; i < GetUsages(property).Length; ++i)
|
|
||||||
{
|
|
||||||
if (GetUsages(property)[i].Value == usage.intValue)
|
|
||||||
{
|
|
||||||
usagePopupIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate rect for configuration button
|
// Calculate rect for configuration button
|
||||||
Rect buttonRect = new Rect(position);
|
Rect buttonRect = new Rect(position);
|
||||||
buttonRect.yMin += _popupStyle.margin.top;
|
buttonRect.yMin += _popupStyle.margin.top;
|
||||||
@ -73,25 +62,22 @@ namespace UnityAtoms.Editor
|
|||||||
// Store old indent level and set it to 0, the PrefixLabel takes care of it
|
// Store old indent level and set it to 0, the PrefixLabel takes care of it
|
||||||
int indent = EditorGUI.indentLevel;
|
int indent = EditorGUI.indentLevel;
|
||||||
EditorGUI.indentLevel = 0;
|
EditorGUI.indentLevel = 0;
|
||||||
var newUsagePopupIndex = EditorGUI.Popup(buttonRect, usagePopupIndex, GetPopupOptions(property), _popupStyle);
|
|
||||||
|
|
||||||
int usageType = GetUsages(property)[newUsagePopupIndex].Value;
|
var currentUsage = property.FindPropertyRelative("_usage");
|
||||||
usage.intValue = usageType;
|
var newUsageValue = EditorGUI.Popup(buttonRect, currentUsage.intValue, GetPopupOptions(property), _popupStyle);
|
||||||
|
currentUsage.intValue = newUsageValue;
|
||||||
|
|
||||||
SerializedProperty valueProperty =
|
|
||||||
property.FindPropertyRelative(GetUsages(property)[newUsagePopupIndex].PropertyName);
|
|
||||||
|
|
||||||
if (usageType == 0 && valueProperty.hasChildren)
|
var usageTypePropertyName = GetUsages(property)[newUsageValue].PropertyName;
|
||||||
|
var usageTypeProperty = property.FindPropertyRelative(usageTypePropertyName);
|
||||||
|
|
||||||
|
if (usageTypePropertyName == "_value" && usageTypeProperty.hasVisibleChildren)
|
||||||
{
|
{
|
||||||
EditorGUI.PropertyField(originalPosition,
|
EditorGUI.PropertyField(originalPosition, usageTypeProperty, GUIContent.none, true);
|
||||||
property.FindPropertyRelative(GetUsages(property)[newUsagePopupIndex].PropertyName),
|
|
||||||
GUIContent.none, true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EditorGUI.PropertyField(position,
|
EditorGUI.PropertyField(position, usageTypeProperty, GUIContent.none);
|
||||||
property.FindPropertyRelative(GetUsages(property)[newUsagePopupIndex].PropertyName),
|
|
||||||
GUIContent.none);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EditorGUI.EndChangeCheck())
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
Loading…
Reference in New Issue
Block a user