Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    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,171
    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.