Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

UIElements custom property drawers?

Discussion in 'UI Toolkit' started by CraigGraff, Sep 15, 2019.

  1. CraigGraff

    CraigGraff

    Joined:
    May 7, 2013
    Posts:
    43
    As far as I can tell these are nonfunctional right now.

    Is this actually the case or am I missing something?
    Is there an expected time when these will work?

    (I tested the example project in 2019.2.5 as well as 2019.3.0b3, but the UIElementsCustomDrawer seems to just be inheriting from ImguiCustomDrawer and not actually doing anything.)

    (I am aware of a hack workaround to make a custom editor for any class that has UIElements property drawers.)
     
    Last edited: Sep 15, 2019
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,046
    I assume you're referring to the Unite LA example. The UIElementsCustomDrawer inherits from ImguiCustomDrawer because it implements one additional override:
    CreatePropertyGUI()

    The way it works is if the
    CustomDrawer
    implements the IMGUI
    OnGui()
    , the system will use it, but if it implements the UIElements
    CreatePropertyGUI()
    , it will ignore the IMGUI UI and use pure UIElements. I just used ImguiCustomDrawer as my base to get the existing functionality but you don't need to do something like that (nor should you).

    There's a more pure example in our scripting docs here:
    https://docs.unity3d.com/ScriptReference/PropertyDrawer.html

    One more thing, and this is probably why you don't see them working right now. UIElements is not yet the default for creating default inspectors. That is, if no custom inspector is defined for a type, it will use IMGUI to generate its inspector. UIElements cannot be embedded inside IMGUI (only the other way around), so any custom UIElements property drawers will not work in a default IMGUI inspector. You have to create a custom UIElements inspector for your MonoBehaviour first. This will be fixed at some point.
     
    Last edited: Sep 17, 2019
  3. CraigGraff

    CraigGraff

    Joined:
    May 7, 2013
    Posts:
    43
    Thank you for the clarification!

    I'm glad to hear this is being worked on, because until this is done my initial assessment seems to be correct (effectively if not technically).

    Hopefully this is something that can make it into the 2019 cycle.
     
unityunity