Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

IMGUI/Unity Ui

Discussion in 'Immediate Mode GUI (IMGUI)' started by paulboutros, Mar 11, 2021.

  1. paulboutros

    paulboutros

    Joined:
    Mar 18, 2013
    Posts:
    30
    Hey ,


    I am starting to use "Immediate Mode" GUI (IMGUI) for some in-game/runtime menu.. and find it 10 times easier/faster to use and manage than Unity UI system that requires tons of layers, and component and set up to do basic stuff. But I just don't understand why it seems like a majority of people don't like it. Am I missing something?

    I heard it is less performant.. ok ...but do I need high performance to run an inventory menu? I don't think so.

    Please can someone point out the real drawback of using IMGUI in my case.. for in -game menus for example?
     
  2. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    5,673
    Yes - you're missing all the scaling, all the fitting to different screen sizes, all the ease of swapping different screens in and out, etc. If you need simple menu buttons, the Unity UI is probably overkill. The Immediate mode GUI is the only option when writing editors. But I wouldn't want to use it for something like an RPG, etc.
     
  3. Fuzzypup

    Fuzzypup

    Joined:
    Aug 13, 2013
    Posts:
    150
    I used the IMGUI for my first game WarPlan and my 2nd game WarPlan Pacific. The entire game menu system runs on it. No Lag no issues ever. If I tried to make the same design with the new system I'd get lost in the intertwining layers. It would be unmanageable.

    For displaying permanent information I think the new system is easier with the canvas, auto scaling, and layout as long as the data is simple. I made a simple display of coordinates that took only 1 object with a rect transform, an image background, and a text.

    I figured out how to make a tooltip hover with the new system. But it requires extra work as each time you have a button, toggle, or list with a tooltip. You need to send the tooltip object the information.

    Where I run into issue is making scrollable lists of anything. I have been trying to learn the new system for many hours over the last year and I can't keep it all in my head. I create the objects but there are so many moving parts to get it right and I still havent figured out how.

    With the IMGUI my code contains the following short classes I created myself
    AutoScroller - for scrolling texts, buttons, and selectiongrids.
    GUIMatrix - for auto scaling. I start it at the start of OnGui and close it at the end if I want to autoscale.
    GUIToolTip - auto tooltip that is placed at the end of OnGui and reads guicontent
    I write wargames so I don't need physics or heavy graphics.

    My IMGUI objects are systemic when called instead of compartmentalized like in the new way.

    I think they meant the new system to be for simpler displays of data. My game shows list of units, their features, I have to sort them, etc, etc, etc. Overly complex data.

    I am trying to find a function that lowers the frame rate for OnGui so there aren't so many calls. There is one for fixed update. Why wouldn't there be one for OnGui?!?

    Some developers like seeing code. It is far easier for me to read code than navigate a complex objects with child objects.

    If I can't get the new system to work, and I have simple needs, with my 3rd game I am designing I am going back to IMGUI.
     
  4. paulboutros

    paulboutros

    Joined:
    Mar 18, 2013
    Posts:
    30
    Hi thanks for the reply, yes indeed it just depend on what's someone intent to do. The missing scaling is a problem, and it gets inconvenient for anyone who tries to do animated thing. At least now, I tested both and see the pros and cons.
     
  5. paulboutros

    paulboutros

    Joined:
    Mar 18, 2013
    Posts:
    30
    "getting lost in the intertwining layers ":
    Well that is what I hated... but really found a solution, just invest time in building solid EditorWindow, where you can , select, show/hide and edit key element of your UI, this way you barely touch the layers or search for anything in the hierarchy and this way you get back to controlling everything by code inside your EditorWindow or CustomInspector( actually in that case, a custom inspector is no good because you must select the right object to display it .. where a floating editor window displys information all the time regardless of what layer you clicked...)

    In some case, where you have dynamically generated data, (stats of different weapons or characters )I personally go for building/instantiating dynamically some part of the UI. For example in IMGUI, if you have an array of 10 items to display, it is easy in your code, you just write ex:
    Code (CSharp):
    1. (pseudo code)
    2. for(int it = 0; it< items.Lenght;i++){
    3.  
    4. Display_item_Button(new Rect(x,y+10*it ,heigh,width), myitem.image  );
    5. }
    Well after all, (with a bit of extra work ) you can do the same with Unity UI, same loop, but with instantiating stuff, I did already and the get the comfort of controlling thing by code...
    Code (CSharp):
    1. (pseudo code)
    2. //Destroy previously created item object
    3. for(int it = 0; it< items.Lenght;i++){
    4.  
    5.  // Instantiate  your item form a new  list etc....
    6. }

    "My IMGUI objects are systemic" that I really do not know what that is ? :)


    "Some developers like seeing code. It is far easier for me to read code than navigate a complex objects with child objects." Again I suggest you kill the time wasted in navigating through these layers.. and do everything thing through a centralized Window editor... that personally made me make peace with Unity UI now that I do not have to deal with this problem...

    Any way, can you show your UI a bit, I am quite interested in complex UI now that I am working on displaying a bunch of character statistic... your UI is probably more complex than mine and that 's the point! :)
     
    Last edited: Apr 10, 2021
  6. paulboutros

    paulboutros

    Joined:
    Mar 18, 2013
    Posts:
    30
unityunity