Browse Source

Fix AnyVarDrawer element overlap

Change Drawer GetHeight to ask sub properties for their heights rather than assuming they are single line.
Fix 844
master
Steve Halliwell 4 years ago
parent
commit
d3a08719c5
  1. 27
      Assets/Fungus/Scripts/Editor/AnyVariableAndDataPairDrawer.cs

27
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;
}
}
}
Loading…
Cancel
Save