I have a classe that use a property drawer with a single foldout, then I have an array of that class.
When I fold or unfold one element of the array, every other open at once.
[CustomPropertyDrawer(typeof(CarouselElement))]
public class CarouselDrawer : PropertyDrawer {
public bool unfold = false;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label){
position.height = 16;
unfold = EditorGUI.Foldout (position, unfold, label);
if (unfold){
/*Draw some properties*/
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label){
return unfold ? 16*4 : 16;
}
}
I take it that ‘unfold’ is being shared across all instances of the class? How am I supposed to keep track of every possible instance individually?
**Edit : **
I did make the check, when creating several different property on a Monobehaviour they will unfold properly with this code, it’s really when creating a array of properties that they somehow get all kined together. Is this some kind of bug or is this by design?