IMGUI/Unity Ui

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?

1 Like

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.

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.

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.

"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:

(pseudo code)
for(int it = 0; it< items.Lenght;i++){

Display_item_Button(new Rect(x,y+10*it ,heigh,width), myitem.image  );
}

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…

(pseudo code)
//Destroy previously created item object
for(int it = 0; it< items.Lenght;i++){

 // Instantiate  your item form a new  list etc....
}

“My IMGUI objects are systemic” that I really do not know what that is ? :slight_smile:

“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! :slight_smile:

Also I am posting some reddit post I made here on that subject, there is great answers from other users there:
https://www.reddit.com/r/gamedev/comments/m2t0ig/unity_imgui_vs_ui_system_for_in_game_ui/

Old thread but adding another perspective. I for one an a huge IMGUI fan. I’ve done complicated runtime game GUIs using it and also lots of tools. The Unity editor is essentially IMGUI. Conversely Unity GUI is too much mouse-monkeying around to get it to work right.

Also, getting IMGUI to scale and work on multiple screens isn’t hard at all. I simply wrote a script which given a GUISkin such as the default one it rips the textures out, doubles them in size, saves them, creates a new GUISkin and doubles those settings, and saves the new GUISkin as a 2x version. Then on load you simply look at the screen size, choose the best fitting skin, then do a Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(Screen.width / 960.0f, Screen.height / 540.0f, 1.0f)) and set the GUI.matrix at the start of OnGUI and done. Works great, scales, fast, etc. Artist can open the texture files and change them to whatever theme they want. We made a simple GUIGallery script which contains demo widgets for everything used in a game/tool and you put this script on a new empty scene’s camera and then set the GUISkin in a public variable and the artist can see the output.

Sorry I missed this reply for 3 years… This is my current game using all IMGUI. This is a screen shot with the menu items on top and the unit selected. I have a master folder for all the guistyles and a class for different button types with styles I use as a master template. All I really have to do is create the Rects.

Anything on the map uses objects with TextMesh. The minimap in the lower right is a sprite that is constructed when the scenario loads. My game has a lot of screens. I even have methods that tell me if the mouse is over the gui. It auto scales. I have a good portion of my players as older wargamers with eyesight problems my UI doesn’t autoscale. I allow them to manually scale it. The average resolution is 1920x1080 but growing is all the way up to 6k.

1 Like