Thinking of switchingg from OnGUI to UI...

I have used OnGUI (I’ll just call it by the function) for deveral projects thus far, and it has served me pretty well with lots of community-created scripts and functions for all kinds of effects and whatnot. I like it’s flexibility and that it doesn’t clutter up my hierarchy.

For my newest project, I wonder if I should really learn to use the new UI system. I know next to nothing about it, but from what I understand it uses one object per UI element, so each image that is displayed, each button and each label has it’s own object, represented in the hierarchy, right? Also, since the system is relatively new, is it as powerful as the old GUI, or are there any serious limitations? Is it mostly aimed at beginners and casual users who just need a simple way of setting up some windows, or is all the detailed functionality that can be expected of a complete user interface included?

I’m not a beginner, and I think in term of performance, in term of visual polish, simplicity of UI scaling between different resolution, modifying your UI like any 3D object in the scene, and the time of work you gain by simply not coding anything for basic functionnality is worth.

Even if the version 5.2 of Unity will fix some actual performances issue, I think personally that OnGUI was far worse for complex UI, in term of perf (especially memory garbage), in term of time you work on it and in term of visual.

We work on a big - small studio scale - project with mostly “UI gameplay”, we change OnGUI to NGUI and then the new UI and, minus some bugs here and there, it was totally worth it. I can’t imagine turn back to NGUI or OnGUI.

2 Likes

The main difference you’ll have to contend with between the legacy GUI and the new UI system is the code.
A lot of people say the new UI system is more complex because there is more to do. However, it is totally worth it.

The state is more visual, easier to design and see on screen what you are building and also designed to use responsive design patterns (if configured right)

Other big thing that changed is the move from an update loop to an event system based approach, meaning you only code for interactions, which can be confusing if you have a lot of legacy gui code.

All in all go for it, your game will be better for it, especially new projects.
P.s.
I’d only update an existing project if you really had to or were planning a UI refresh. If your game is heavily dependant on the legacy GUI, just leave it alone (if it ain’t broke, don’t fix it) else you will have a lot of work which your players wont likely see. Have a reason to update.

Thanks for the inout. After some dabbling aroudn and setting up a simple inventory system, I have come to the conclusion that the UI has lots of nice functionality nad is pretty sleek, but seems to be geared primarily to pre-set up environments like. However, it can become a nightmare when using it in a dynamic way; I have a button for each item in a list in my backpack, and this button needs to be instantiated in the right place and also needs it’s Listener added when picking up an item. It’s a complex task having to keep track not only of the actual items in a list, but also of the buttons that correspond to the items. It gets worse if additional UI elements need to be instantiated/activated, for example an indicator that an item is equipped or given a hotkey: The right button needs to be found, and the indicator UI object added to it.For my purposes, it has been a mixed bag so far, but I’ll likely stick with it.