Skip to content

Property Painter

  1. Create new folder and name it Editor.
  2. Inside Editor folder create new class, ExamplePainter.cs

    public class ExamplePainter
    {
    
    }
    

  3. Inherit from PropertyPainter class.

    public class ExamplePainter : PropertyPainter
    {
    
    }
    

  4. Implement virtual method OnPainterGUI.

    public class ExamplePainter : PropertyPainter
    {
        public override void OnPainterGUI(Rect originalPosition, Rect painterPosition, SerializedProperty property, GUIContent label)
        {
            // Painter GUI here...
        }
    }
    

  5. Add PainterTarget attribute and set ExampleAttribute as target to this view.

    [PainterTarget(typeof(ExampleAttribute))]
    public class ExamplePainter : PropertyPainter
    {
        public override void OnPainterGUI(Rect originalPosition, Rect painterPosition, SerializedProperty property, GUIContent label)
        {
            // Property GUI here...
        }
    }