- Home /
PropertyDrawer not painted when scrolling upwards
I am painting my properties in the following way:
EditorGUI.PropertyField(position, property, true);
position.y += 18f;
//... repeat same pattern 2 more times
I also override GetPropertyHeight, i know its always 54, since i use 3 properties.
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) => 54;
This property drawer paints correctly in Inspector when :
1) The entire monobehavior fits on inspector. (54 pixels free). Example: Most of the times.
2) When drawn from top to bottom (even if not fit in inspector). Example: When you scroll downwards.
The error condition comes up when you scroll upwards ie when it draws from bottom to top.
Then only 1 property is drawn (the last, lets call it C) or none and the rest of monobehavior space (~54 pixels) is left empty. Therefore it under-draws, it doesn't paint properties A, B (the first ones), but paints property C, then a huge space 54 pixels is left. If it was smart it could fit all 3 properties in all that space.
More Details (probably irrelevant): Between property draws, to move to next property i use:
property.NextVisible(false);
No exceptions are thrown. I don't understand where the bug is created from. Is this a unity bug?
$$anonymous$$ore details... This "empty space" it re$$anonymous$$ds me of ....
Assumption: Unity engine is thinking that my "component" is in "expanded" mode (as if array/serializable class), thus allocates an additional 54 pixels without asking me. Why? How do i disable this unity behaviour.
Also this happens only when you scroll upwards => very rare bug.
Assumption confirmed: property.isExpanded = false; fixes the issue.