- Home /
Best Practice: 3D GUI or Built-in uGUI?
I see two main ways of implementing GUIs in Unity:
Using the built-in
GUI()
andGUILayout()
functionsUsing a separate Camera and with Quads to make the various controls.
What is the best practice regarding this? Is it completely dependent on application?
Which method is less performance-heavy, especially considering mobile devices?
Answer by Zodiarc · Sep 22, 2014 at 09:06 AM
You could also download the latest Unity 4.6 stable beta and use the new UI system. http://unity3d.com/unity/beta/4.6
Overview: https://www.youtube.com/watch?v=EOX6itCuKOc
You can also use the unity animation system to make nice transitions and fade-in or fade-out effects.
Protip: If you want to add a listener to a button programatically, it's not very obvious and they don't appear in the inspector.
Here's the code:
var button: UnityEngine.UI.Button = ButtonDoingStuff.GetComponent("Button");
button.onClick.AddListener(function() {<CALL YOUR FUNCTION HERE>});
Or you can also define an action and pass it to the Listener:
var action: UnityEngine.Events.UnityAction;
action = function() {<CALL YOUR FUNCTION HERE>};
Answer by bradmarxmoosepi · Sep 22, 2014 at 09:04 AM
For instance, I see some advantages and disadvantages of the 3D method:
Advantages:
Can use
AnimatorControllers
to give excellent effects like fade-ins and fade-outsCan do more advanced things, such as radial controls, easier than with the built-in GUI system
Can incorporate 3D models into the GUI if you wish
Can give perspective, shadows, etc. very easily
Disadvantages:
Scripting becomes slightly messy, as either each control needs to have its own script to control its behaviour, or a very monolithic controller class with handles to each of its controls has to be written.
Dynamic lists, which could easily be handled by
ScrollViews
become a little more tricky
Your answer
Follow this Question
Related Questions
GUI.Window error. InvalidOperationException: Hashtable.Enumerator: snapshot out of sync. 0 Answers
know GUILayout current screen position 2 Answers
"'UnityEngine.GUI.DoTextField' is inaccessible due to its protection level." 1 Answer
Grid of GUILayout buttons? 1 Answer
Why can't I get my tooltip to show only when there is a tooltip set? 2 Answers