Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

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,125
    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.