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
  3. Dismiss Notice

Question How to write a list drawer attribute.

Discussion in 'Editor & General Support' started by madGlory, Aug 4, 2020.

  1. madGlory


    Jan 12, 2016
    How is one supposed to write an attribute to display a list differently in unity?

    I have tried this:
    Code (CSharp):
    1. public class CoolListAttribute : PropertyAttribute {
    3. }
    Code (CSharp):
    1.     [CoolList]
    2.     public int[] exampleIntArray;
    Code (CSharp):
    1.     [CustomPropertyDrawer(typeof(CoolListAttribute))]
    2.     public class CoolListAttributeDrawer : PropertyDrawer {
    4.         public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
    6.         }
    8.     }
    But for some reason, this seems to only affect the ints inside the list and not the list itself.

    Is it possible to create a PropertyAttribute that can display the list differently?