- Home /
Other
Unity Developers why remove OnGui?
Hello all,
There is probably a better forum place to ask this question but i don't know where that would be.
As the title states I am wondering why the unity Developers saw it as a whise move to remove the old OnGui system and replace it for their as they call it: "You should use Unity’s up-to-date UI system instead"
I get that they like to change things and improve their engine and I get that they want to make it more accessible to make an UI. The idea is that you should be able to manage everything from inside the editor and don't need to use code to create an UI, and since artists are the once mostly focused on creating the UI this way they should be able to make it from the editor right?
This is true basically anyone can start making an ui right now instead of needing to be able to code to make an ui. But its restricting to use the editor ui. And trying to make the buttons from the new ui fully by code is an absolute nightmare.
void OnGUI()
{
if (GUI.Button(new Rect(10, 10, 150, 100), "I am a button"))
{
print("You clicked the button!");
}
}
HOW SIMPLE CAN IT BE? ofcourse this is the easiest version of a button but still just try and do the same with creating a button with the new ui, here are a few things you have to do: create 2 gameobjects (one for the button and one for the text)
add a recttransform for both
define anchor points for the recttransform
set the size (and no not using the normal transform.position and transform.size etc. but the recttransform versions which are just weird after being used to using gameobject.transform
set the parent canvas add component image add component button
and many many more things just to create a normal button, seriously why unity developers? OnGui was so easy to use so simple so why did you have to force the new UI system on us? Why did you have to remove the OnGui system? why not just leave it running next to the UI system?
edit(moved from answer)
You might be wondering what prompted this question....
I have been working with both system on many different projects, but right now because of hardware i need to use 2019 so OnGui is no more in this version.
In the project that I'm working on everything needs to be scaled correctly with the screen on both axis does this work properly right now with the UI system? NO. Would this have been an easy fix using OnGui? YES. What does this mean for my project? I need to make every UI part with code to be able to change sizes fonts and everything else by code! So a system focused on working solely from the editor is terrible to mimic using code, its just plain awful compared to writing the same with OnGui. I have been spending a long time first setting it all up in the Hierarchy first of all its way to much to wanting to have it all in hierarchy but sure its meant to be build in the Editor so I comply. I finish it turns out I cant make it work with what I need
It takes up way to much resources to have it all in the Hierarchy
It is a nightmare to change the ui elements from code while its in the Hierachy
So right now I'm recreating the Whole ui by code and im looking at this hot mess and just wheep thinking how much more streamlined and optimized OnGui would have looked in comparison!
I invite you to post on the forum ins$$anonymous$$d. The developpers of the Unity engine don't browse Unity Answers.
Well it's Novermber 2020 and I$$anonymous$$GUI is still here. I really hope they don't remove it anytime soon as I would have to re-do all my tools from scratch, which will be a massive friggin pain.
I tried the UIElements/UIToolkit and really hate it. It has some nice bonuses but also hits a few brick-walls that need ironing out before I consider it a half-way viable tool.
I don't think it will be removed any time soon, at least not for the editor. Keep in $$anonymous$$d that 90% of the editor UI is build with I$$anonymous$$GUI. AFAIK they are in the process of replacing the editor ui with UIElements as they both simplify complex ui setups and also provide performance optimisations from the ground up which aren't possible in a pure immediate mode gui. I'm sure when they have a viable solution for easily creating property drawers, custom editor, custom editor windows and wizards with UIElements they may start phasing out the I$$anonymous$$GUI system. Though I don't think that happens any time soon and if they plan to do it they usually have a longer transition period (usually a year+).
At the moment all official tutorials for editor coding uses I$$anonymous$$GUI all the way. For quite a long time the new UIElements were in the experimental namespace. At the moment Unity does not recommend to use UIElements in production as it's still under development.
Answer by Bunny83 · Feb 28, 2019 at 02:05 PM
There are several things not clear here.
First of all the latest stable Unity version at the moment is something around 2018.3. Any 2019 release are beta releases which shouldn't be used in any production yet. If you have no idea what a beta version is good for, have a look at beta version.
I just installed the 2019.2.0a6 version and the IMGUI is still present, can be used and doesn't generate any warnings or errors.
So I don't quite get the point of the question. I don't know which version you used which may not include the IMGUI system. I also haven't heard about any plans to remove the IMGUI system from the runtime. I agree that this would be a bad move, at least they should make it an optional module in order to keep the engine small for those who don't need it.
Switching Unity versions during production is generally a bad idea. Let alone switching to a beta release. Switching to a patch release of your currently used version would be ok. Though if you are in the middle of a project you shouldn't upgrade Unity. That's why some people still use Unity 5.x.
Answer by Rick66 · Feb 27, 2019 at 09:57 PM
The name was changed to immediate mode GUI (IMGUI) several versions ago
I am assuming that it is still available as it is listed in the 2019.1b Manual under UI, or am I mistaken?
https://docs.unity3d.com/2019.1/Documentation/Manual/GUIScriptingGuide.html