Hi all,
I have a script with a number of parameters.
The class of the script derives from another script.
When I see the parameters in the editor, the superclass properties are shown before the subclass ones.
I need to show the subclass properties first and the subclass properties then.
most straightforward way is to simply write an editor script that explicitly defines the order that the parameters are rendered. you can even go so far as create a class heirarchy of the editor scripts that overrides the base.OnInspectorGUI, and render their properties before, or after the base class
My real question is: is it possible to achieve the same result by changin any property “order”, “index” or decorating the serialized property in some way in the source script without passing through an editor script?
Since there is no any kind of “order” attribute, you can use Tooltips to sort the list of properties. Just write [Tooltip(“0. Some text”)] or [Tooltip(“Some text, Order(0)”)] or use other scheme, parse the numbers inside OnEnable() method and sort properties. It is a hack, but it works. This way you can easily sort all variables from base and derived classes.
Why would you use / abuse the Tooltip attribute for that? Why don’t you create your own “Order” attribute? Keep in mind that other properties like Tooltip, Header, Space, … belong to the property that follows. So reordering them may render those attributes / decorators pointless, faulty or at least may not do what you expect or wanted.