Search Unity

Unity Editor UI is rich and poor at the same time

Discussion in 'Immediate Mode GUI (IMGUI)' started by IC_, Jun 25, 2019.

  1. IC_

    IC_

    Joined:
    Jan 27, 2016
    Posts:
    64
    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.<static fields> 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:
    https://forum.unity.com/threads/drawing-a-field-using-multiple-property-drawers.479377/ (Disputes about GetPropertyHeight and float? return value of this)
    https://forum.unity.com/threads/ongui-inspector-displays-differently-on-second-monitor.698438/
    https://forum.unity.com/threads/getting-current-rects-width.693088/
    ... to be continued
     
    Last edited: Jun 25, 2019
  2. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317