Search Unity

Resolved The future of Property and Decorator Drawers

Discussion in 'UI Toolkit' started by vertxxyz, Aug 26, 2022.

  1. vertxxyz

    vertxxyz

    Joined:
    Oct 29, 2014
    Posts:
    109
    I've developed endless amounts of editor extensions and while Unity's felt flexible since the start, I've always run into the same painful limitations. UIToolkit's stateful nature has for years allowed me to perform some hacks I've not had the luxury of performing with IMGUI, but it's not been a particular boon to what I'd like to be doing: improving upon basic fields and making these improvements coexist with others.

    Last I asked there was an indication that something similar to nesting property drawers was being considered. This would allow basic things—like a ReadOnly drawer—or more complex things—like a SerializeReference drawer—to combine with any other drawer without hacks.

    As a related but very specific aside:
    I've just been adding UITK support to my SerializeReference decorator, and while I'm glad that I'm not IL weaving the editor DLL as I have with the IMGUI version (to support nested property drawers), I am still performing some very full on and tedious to manage tricks!
    I'm using decorator drawers because you can have multiple on a single property. I use events to hack around and find the PropertyField, and use reflection to get the SerializedProperty. Then seeing as decorators aren't drawn on collection elements, I also have to turn those off, and inject my own fake decorators into the ListView's elements. I have to jump through a ton of hoops to maintain these elements and events as UITK loves to overwrite it all without firing any relevant change callbacks. Then, when I'm done with it all I'm always left with a buggy mess, presumably as there's no built-in UI for them this leads to very little test coverage!

    Here's an in-progress peek at that nightmare. And here's a video of me just trying to use the thing and experiencing how busted property fields just appear to be with this setup.
    Once I'm slightly further along someone's going to be getting a bug report with like 3-5 UITK SerializeReference-related bugs in it, so look forward to that.​


    Anyway, will drawers become more flexible any time soon?
    Are there plans for a SerializeReference type picker?
    Will someone please add zooming (and 1x zoom) to the texture preview window? You can steal my old implementation if you want.
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    Since you're basically quoting my 2020 post, I'll try to add more context. In short, there's no major progress on the investigation I mentioned in my 2020 post. We were working on a way to "nest" (more like stack) PropertyDrawers, but it was still IMGUI-based and we had some trouble translating the pattern to UI Toolkit. But priorities shifted and we never shipped anything. It's still in the plan though.

    Your own implementation is indeed very cool though.

    Looking forward to it!

    Nothing to share in terms of plans for either, at this time. But dually noted.
     
    vertxxyz and karl_jones like this.