- Home /
GUI and Screen Resolution
Hello, I know that this question have been asked a lot of times, but it seems that all the posted solutions aren't working for me. I've designed my GUI using Unity built in player in "Maximize on Play" mode ( that should be 1280*854 ), but I can't resize it properly to work at ie. 921*428 (the Unity built in player normal resolution).
This is the code I used (inside OnGUI() function):
scale.x = Screen.width/1280.0f; // calculate hor scale
scale.y = Screen.height/854.0f; // calculate vert scale
scale.z = 1;
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);
What's going wrong with it ?? Many thanks
EDIT: I've noticed that GUI.Button and GUI.Label are scaled correctly with that code, but GUI.Window seems that isn't scaled correctly.
Answer by Luca91 · Apr 28, 2013 at 03:17 PM
I've fixed it, it was my fault, I was using Screen.width/2 and Screen.height/2 to center the GUI.Window .. I fixed changing it to:
GUI.Window (0, new Rect((Screen.width/2)/scale.x , (Screen.height/2)/scale.y, 950, 700), MainMenu, MyGame);
Thanks anyway :)
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 adapting to screen resolution? 3 Answers
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