- Home /
Need help fixing my GUI
Here is a video of the issues. Regardless of the resolution, they go off screen, and are not scaled to the resolution of the screen. I need it to where they will be center of the screen, and not go off screen on smaller devices. I have every setting to center, and declaring them default. I have no special settings in declaring them in my script. How can I do this? https://www.youtube.com/watch?v=jKpIMmDlwrY
GUI.Label(new Rect(Screen.width / 2, Screen.height / 2 - 150, 125, 25), "Classification: Legendary", myStyle);
GUI.Label(new Rect(Screen.width / 2, Screen.height / 2 - 125, 125, 25), "Connections: " + LegendConnect, myStyle);
GUI.Label(new Rect(Screen.width / 2, Screen.height / 2 - 100, 125, 25), "Time: " + LegendTime, myStyle);
Answer by troien · Nov 05, 2014 at 09:58 PM
A Rect's x and y positions are based on the top-left corner. not on the center. Therefore you need to substract half the width/height of your rectengle to center it.
So
new Rect(Screen.width / 2, Screen.height / 2 - 150, 125, 25)
Should be changed to:
new Rect((Screen.width / 2) - (125 / 2), (Screen.height / 2) - (25 / 2), 125, 25)
etc.
Your answer
Follow this Question
Related Questions
Rendering GUI.Buttons in the middle of the screen 5 Answers
UGUI Scaling across multiple monitors 0 Answers
Fixed to the screen GUI ? 1 Answer
Set GUI buttons and GUITextures in fixed place 2 Answers
GUI adapting to screen resolution? 3 Answers