I would like to create my own inspector window. Users can drag an object from hierarchy view to my window and it displays only attributes of component types I allow.
I have done drag and drop part, and be able to grab my custom components. The problem is I don’t know how to display attributes. Because I don’t know type of each attribute before hand, I cannot just simply use GUIEditor.floatField() or else.
There is any function that I can put variable in, and GUI can automatically draw a correct control based on type I put in.
Or some kind of pre-made treeview like inspector window.
You should also look into PropertyDrawers. You could make a property drawer for each type of property (even the complex one, having sub-values), and the defined drawer kicks-in when drawing a particular property type.
Thank you. How can I get property for each variable? I’ve tried using [CustomPropertyDrawer(typeof( MyClassA ) )]. I can get properties if MyClassA is not MonoBehavior. But I need to inherit MonoBehavior in MyClassA, so I can assigned it to GameObjects.
Property drawers are meant for rendering editor UI for some serialized value (so you can edit the value). You don’t want the value to be of the MonoBehaviour type (you want it to be of int, string, Color or similar)!