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

Question DrawDefault for PropertyDrawers?

Discussion in 'UI Toolkit' started by backwheelbates, Aug 15, 2023.

  1. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    225
    Hi all,
    I just wanted to stick a button or two on top of a class (or on each element of a class in a list).

    With an Editor script using OnInspectorGUI, I can easily add some buttons and put "DrawDefaultInspector()" at the bottom to continue drawing normally.

    Is there a property drawer equivalent for this?

    Thanks!
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    Probably just using PropertyField and supplying the serialised property the property drawer gives you.
     
  3. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    225
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    Right, a property field would just invoke the property drawer and go infinite...

    In your instance I think you want a DecoratorDrawer instead, actually, now that I remember them.
     
  5. oscarAbraham

    oscarAbraham

    Joined:
    Jan 7, 2013
    Posts:
    431
    Hi. What version of Unity are you using?
     
  6. backwheelbates

    backwheelbates

    Joined:
    Jan 14, 2014
    Posts:
    225
    Im on 2022.2.15 @oscarAbraham

    I did a test manually by using CreatePropertyGUI, its actually not to difficult to use this, way simpler than OnInspectorGUI. Since I only wanted to add a button and not really change anything, I dont want to keep updating the property drawer every time I change the class.

    Id like the button to call a function on the specific data of that object/instance.
    @spiney199, is this something that DecoratorDrawers can do?

    upload_2023-8-16_11-24-15.png
     
  7. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    Actually looking at the docs, you don't get access to the serialised property for some reason?? So I guess not.

    This is why I use Odin. Unity's inspector tools just leave too much to be desired.