From d3a08719c52aa597acf466cf6b6668e2fbcb4c2c Mon Sep 17 00:00:00 2001 From: Steve Halliwell Date: Mon, 22 Jun 2020 21:10:02 +1000 Subject: [PATCH] Fix AnyVarDrawer element overlap Change Drawer GetHeight to ask sub properties for their heights rather than assuming they are single line. Fix 844 --- .../Editor/AnyVariableAndDataPairDrawer.cs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Assets/Fungus/Scripts/Editor/AnyVariableAndDataPairDrawer.cs b/Assets/Fungus/Scripts/Editor/AnyVariableAndDataPairDrawer.cs index d1cc7591..96c5c58e 100644 --- a/Assets/Fungus/Scripts/Editor/AnyVariableAndDataPairDrawer.cs +++ b/Assets/Fungus/Scripts/Editor/AnyVariableAndDataPairDrawer.cs @@ -61,7 +61,32 @@ namespace Fungus.EditorUtils public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { - return EditorGUIUtility.singleLineHeight * 2; + //changes in new Unity circa UIElements mean that some data that used to be single line + // are now multiple lines, so we have to ask the props individually how high they are + var dataProp = GetDataProp(property); + + return EditorGUI.GetPropertyHeight(property.FindPropertyRelative("variable")) + + (dataProp != null ? + EditorGUI.GetPropertyHeight(dataProp) : + EditorGUIUtility.singleLineHeight); + } + + protected SerializedProperty GetDataProp(SerializedProperty property) + { + var varProp = property.FindPropertyRelative("variable"); + if (varProp.objectReferenceValue != null) + { + var varPropType = varProp.objectReferenceValue.GetType(); + + var typeActionsRes = AnyVariableAndDataPair.typeActionLookup[varPropType]; + + if (typeActionsRes != null) + { + var targetName = "data." + typeActionsRes.DataPropName; + return property.FindPropertyRelative(targetName); + } + } + return null; } } } \ No newline at end of file