From b2e302498df74e3cc1ad0ce265c40619e9920bb9 Mon Sep 17 00:00:00 2001 From: Soraphis Date: Sat, 22 Oct 2022 23:53:10 +0200 Subject: [PATCH] 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 --- .../Core/Editor/Drawers/AtomBaseReferenceDrawer.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Packages/Core/Editor/Drawers/AtomBaseReferenceDrawer.cs b/Packages/Core/Editor/Drawers/AtomBaseReferenceDrawer.cs index f844a579..cdfcfdac 100644 --- a/Packages/Core/Editor/Drawers/AtomBaseReferenceDrawer.cs +++ b/Packages/Core/Editor/Drawers/AtomBaseReferenceDrawer.cs @@ -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 {