Search Unity

Question PropertyDrawer for Array Item Add Event.

Discussion in 'Immediate Mode GUI (IMGUI)' started by atmuc, May 19, 2023.

  1. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    I made a custom property drawer for array. OnGUI function is called for each item in array. How can I write a PropertyDrawer to get item added/removed events?

    Code (CSharp):
    1.  
    2. [OnCollectionChanged("OnTestListChanged")]
    3. public string[] TestList;
    4.  
    5. [CustomPropertyDrawer(typeof(OnCollectionChangedAttribute))]
    6. public class OnCollectionChangedDrawer : PropertyDrawer
    7. {
    8.  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    9. {
    10. }
    11. }
    12.