- Home /
Auto- scale Gui button
Hello everyone.
I have one question, I did button and I set positions but this button behaves differently and is in different locations depending on the screen resolution.
How to do that was all the time in a fixed position? Regardless of the resolution?
if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2 - 100,250,50), "Play"))
You just have to fix the the Top and Left arguments. Right now they are depending on the Width and Height of the screen.
GUI.Button(Rect(0, 0, 250, 50), "Play"); // This will position the button at the top-left corner of the screen.
making a simple search on google or even this website could save you and us some time, this question is asked like several times a week ...
http://forum.unity3d.com/threads/85909-Giving-a-GUI-Text-a-fixed-position
Answer by Propagant · May 23, 2014 at 03:07 PM
if(GUI.Button(Rect(20,20,250,50), "Play"))
This is a simple position of GUI... Try next positions for example: ...20,300... ...300,20... ...250,350... (Top, Left) And many many more GUI positions... I using this:
if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2 - 100,250,50), "..."))
When I want middle center the GUI...