Search Unity

Question Is it possible to make PropertyDrawer or Custom Editor aware of the context it is rendered in?

Discussion in 'Immediate Mode GUI (IMGUI)' started by alexpaulr, Feb 5, 2022.

  1. alexpaulr

    alexpaulr

    Joined:
    Jan 10, 2022
    Posts:
    4
    Hi all,

    I want to be able to set up large and complex object literals in my script graphs to use them as config arguments to method calls. I started out trying to instantiate a list of audio sample parameter configurations by creating a literal node for my custom class. Turns out the inspector rendering inside of my node is pretty glitchy. There simply isn't enough space to render a list of objects inside of the unit on the graph. I think I could make the UI render just fine in the Graph Inspector sidebar with a custom UI.



    I could solve this by (auto)changing the width of my script node, but this isn't supported afaik. So I wanted to ask if it is possible to provide custom property drawers or custom editors with some sort of context, indicating where they are being rendered, i.e. if they're being called from inside of an editor window, the graph inspector sidebar or from inside of a script graph unit, so I can disable the rendering in the unit.

    Thank you for your help in advance!

    Btw, this is my post in the VS forum where I go into details about what I want to achieve and also lay out an approach to use references to scriptable objects that only appear as drop targets in graph nodes and are editable in the inspector, but I couldn't figure out how to instantiate and serialize SOs together with a script node (I didn't want to create and reference an SO asset for every node). It's still unresolved, so I'd appreciate your help with either approach a lot!