- Home /
GUI adapting to screen resolution?
Hello
I was wondering how I can get the GUI to adapt to every resolution. Is there a quick function to make all GUI adapt to the screen resolution? If not I will have to write a script that adapts the GUI, but it would be much easier if there is a quick way to make the GUI adapt to the current screen resolution.
Any helpful answers/comments are welcome.
Answer by robert_mathew · Dec 01, 2012 at 11:41 AM
GUI.Button(new Rect(Screen.width * (1f/6.55f),Screen.height * (0.1f/6.3f),Screen.width * (4.8f/6.55f), Screen.height * (0.85f/6.3f)),"Click"); //c#
GUI.Button(Rect(Screen.width * (1f/6.55f),Screen.height * (0.1f/6.3f),Screen.width * (4.8f/6.55f), Screen.height * (0.85f/6.3f)),"Click"); //java script
hi, can you explain where are you find this numbers please?
Answer by DragonshiDev · Dec 01, 2012 at 12:43 PM
I would suggest if you would like to have a picture all over the screen use, (if you use a GUI.Box)
GUI.Box(Rect(0,0,Screen.width, Screen.height), "");and to change size of it use some math like Screen.width * 0.5, then you get 50% of the screen and so on
Answer by DragonshiDev · Dec 01, 2012 at 12:43 PM
test to use
Screen.widht * (what percent of the screen you want in decimals)or
Screen.height * (what percent of the screen you want in decimals)
Your answer
Follow this Question
Related Questions
How to maintain high resolution custom background images for GUI elements on different screen sizes? 0 Answers
GUI and Screen Resolution 1 Answer
Rendering GUI.Buttons in the middle of the screen 5 Answers
Scaling GUI When Screen Width is Adjusted 1 Answer
How to retain absolute gameobject size in pixels no matter the resolution? 2 Answers