fix: #353 "Vector2/3 reference not properly showing" (#359)

* fix: #353 while keeping #289 fixed

* Fix height of popup (was covering click area of expanded type's properties)

Co-authored-by: Adam Ramberg <adam@mambojambostudios.com>
This commit is contained in:
Soraphis 2022-10-22 23:53:10 +02:00 committed by GitHub
parent a41a7f4abe
commit b2e302498d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,6 +56,7 @@ namespace UnityAtoms.Editor
// Calculate rect for configuration button
Rect buttonRect = new Rect(position);
buttonRect.yMin += _popupStyle.margin.top;
buttonRect.yMax = buttonRect.yMin + EditorGUIUtility.singleLineHeight;
buttonRect.width = _popupStyle.fixedWidth + _popupStyle.margin.right;
position.xMin = buttonRect.xMax;
@ -70,9 +71,14 @@ namespace UnityAtoms.Editor
var usageTypePropertyName = GetUsages(property)[newUsageValue].PropertyName;
var usageTypeProperty = property.FindPropertyRelative(usageTypePropertyName);
if (usageTypePropertyName == "_value")
var expanded = usageTypeProperty.isExpanded;
usageTypeProperty.isExpanded = true;
var valueFieldHeight = EditorGUI.GetPropertyHeight(usageTypeProperty, label);
usageTypeProperty.isExpanded = expanded;
if (usageTypePropertyName == "_value" && valueFieldHeight > EditorGUIUtility.singleLineHeight + 2)
{
EditorGUI.PropertyField(usageTypeProperty.hasChildren ? originalPosition : position, usageTypeProperty, GUIContent.none, true);
EditorGUI.PropertyField(originalPosition, usageTypeProperty, GUIContent.none, true);
}
else
{