Script the UI or do it in the Hierarchy, which case to use which one of them?
I found it is difficult to judge which case to use UI in script or assign it in the hierarchy: I usually do it like this in script:
void OnGUI(){
// GUI.Label(XXX)
if (GUI.Button (new Rect (Screen.Width * .5f, Screen.Height * .5f, 100, 100), "button")){
// do something
}
}
It is convenient to control it in the script. But dont work properly in different resolution. So I try to use it in hierarchy, it work properly in different resolution, but not convenient to control. So I want to know that which case to use which one of them will perform better.
Answer by bla_whi · Sep 16, 2017 at 02:21 PM
UI: Positioning an element relative to another element with Scale With screen Size
PS. Dont place UI objects with scripts unless you absolutely have to! Use the UI tools, and set these within the editor.
Your answer
Follow this Question
Related Questions
how do i get a slider value to stay the same after a scene change? 0 Answers
Enabling/ Disabling UI Panel>Scroll Rect> content objects when Screen /Off screen 0 Answers
On Button Click Create a gameobject (ui,no mouse stuff) 1 Answer
5.6.0 - Changing Text in new UI tools via script 1 Answer
Spawn prefab on UI button click 0 Answers