We can expose useful things into an editor to make our lives easier and there’s even no need to derive it from specific class if you don’t want to, just add [Serializable] attribute
But
I is sooo scattered if you plan to make some useful extensions for editor that should add more functionality than attributes can give.
Firstly, Unity library has a lot of similar stuff like EditorGUI, EditorGUILayout, GUI, GUILayout. The only difference is that classes without Layout suffix requires hardcoded sizes and positions of elements (and it is too hard to calculate relative coordinates. Better just not to use it ever). GUI can be used in game UI but who uses GUI to draw GUI in 2019?
What’s the difference between
GUILayout.TextField and EditorGUILayout.TextField?
No difference.
The same thing for Label (but methods has different names)
Styles.
What’s the reason to have EditorStyles and GUI. if they are pretty similar? EditorGUILayout can do more things that GUILayout cannot?
It’s just the tip of the iceberg when you want to make a custom property drawer which disallows you to use GUILayout things (what’s the reason? it’s so silly)
Why aren’t we able to embed SO inline in component’s serialized field?
Instead of this
make this
By the way about SO editor customizing. Can you add a button in SO to say, randomize some values in it? No, you can’t (I think in unity source code SO’s inspector class has very different inheritance hierarchy than MonoBehavours’s inspector class and I guess [Serialized] classes and structs too so you need to learn multiple ways to code editor gui)
Embedding things could allow us to make inline editors or visualizers. Earlier I did a noise/voronoi diagram visualizer right in component’s inpector using a stub sealed class VoronoiPreview
(Just to make it shown) and made a property drawer with raw GL calls. It was too hard to make work and to be correctly shown
I found some old code but i’m not able to compile it now and show how does it look inside unity // TODO
Code of “previewable”
Component having preview
p.s. sorry if my speech seemed primitive to you or has any mistakes. I’m not native English speaker
As a former html/css/js-dev I swore that will never get back to html/css stack but now I’m dreaming about them in unity out of the box
In my mind Unity UI need a full rework
Related posts about UI poorness:
Drawing a Field Using Multiple Property Drawers (Disputes about GetPropertyHeight and float? return value of this)
OnGUI Inspector Displays Differently on Second Monitor
Getting Current Rect's width
… to be continued