From 576afed000ef727e1abfa9f5f2f771e2eb3e1448 Mon Sep 17 00:00:00 2001 From: Oliver Biwer Date: Fri, 27 Oct 2023 20:32:15 +0200 Subject: [PATCH] Fixing a Rendering issue of QuaternionReferenceDrawer due to an unity bug with the result of GetPropertyHeight for Quaternion properties we need to handle Quaternions as special cases Commit-Type: Bugfix --- Packages/Core/Editor/Drawers/AtomBaseReferenceDrawer.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Packages/Core/Editor/Drawers/AtomBaseReferenceDrawer.cs b/Packages/Core/Editor/Drawers/AtomBaseReferenceDrawer.cs index f1b82f5a..080f4636 100644 --- a/Packages/Core/Editor/Drawers/AtomBaseReferenceDrawer.cs +++ b/Packages/Core/Editor/Drawers/AtomBaseReferenceDrawer.cs @@ -82,7 +82,14 @@ namespace UnityAtoms.Editor { var expanded = usageTypeProperty.isExpanded; usageTypeProperty.isExpanded = true; - var valueFieldHeight = EditorGUI.GetPropertyHeight(usageTypeProperty, label); + var valueFieldHeight = usageTypeProperty.propertyType switch + { + // In versions prior to 2022.3 GetPropertyHeight returns the wrong value for "SerializedPropertyType.Quaternion" + // In later versions, the fix is introduced _but only_ when using the SerializedPropertyType parameter, not when using the SerializedProperty parameter version. + // ALSO the SerializedPropertyType parameter version does not work with the isExpanded flag which we set to true exactly for this reason a (few) lines above. + SerializedPropertyType.Quaternion => EditorGUI.GetPropertyHeight(SerializedPropertyType.Vector3, label), + _ => EditorGUI.GetPropertyHeight(usageTypeProperty, label), + }; usageTypeProperty.isExpanded = expanded; if (usageTypePropertyName == "_value" && (valueFieldHeight > EditorGUIUtility.singleLineHeight + 2))