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!
Probably just using PropertyField and supplying the serialised property the property drawer gives you.
Thanks for the reply @spiney199 .
It looks like Im not the first to run into this.
Hello!
I was wondering if there’s a (new? better?) way to implement property drawers using UIElements instead of the good ol’ IMGUI.
Thanks!
I am trying to wrap my head around this concept. So I was wondering, if I make a button like so
VisualElement root = rootVisualElement;
StyleSheet styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Scripts/Editor/UIElements/ShaderSelector.uss");
VisualElement but = new Button();
but.styleSheets.Add(styleSheet);
but.name = "fred";
root.Add(but);
Is there anyway to add Text to the Button via code? ie Do I have to use .UXML to put in text on the button?
Please clarify.
I havent gotten one of the solutions to work yet without freezing Unity.
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.
Hi. What version of Unity are you using?
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?
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.