[Serializable]
public class FooEvent : UnityEvent<string>
{
}
[Serializable]
public class Foo
{
public string Name;
public FooEvent FE;
}
I am writing PropertyDrawer for Foo. Normally, GetPropertyHeight can be calculate EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing but the height of FooEvent should be dynamic. How do I calculate the height?
.FindPropertyRelative("m_PersistentCalls.m_Calls")
I had to dig pretty deep into Unity code to get that one. Don’t ask me what it means, because I’ve forgotten.
Magic numbers:
3.5f - Initial size of the property block with 0 or 1 items.
2.61f - seems to be the best multiplier for dynamic growth. Any smaller and the +/- buttons get covered. Any bigger and you get empty space. (results may vary depending on monitor/resolution??)