- Home /
keep gui text object in the corner of the screen regardless of resolution
the above ^ how do i do it?
Comment
Answer by pSupaNova · Oct 04, 2010 at 08:17 PM
Use Screen.Width or Screen.Height. in C# to put a box in the four corners of the screen in a resolution independent way.
void OnGUI () {
GUI.Box (new Rect (0,0,100,50), "Top-left");
GUI.Box (new Rect (Screen.width - 100,0,100,50), "Top-right");
GUI.Box (new Rect (0,Screen.height - 50,100,50), "Bottom-left");
GUI.Box (new Rect (Screen.width - 100,Screen.height - 50,100,50), "Bottom right");
}
Hello,
JS would be identical to pSupaNova's example, except change the first line to: "function OnGUI(){"
Answer by IJM · Oct 04, 2010 at 08:24 PM
You can use Screen.width and Screen.height to get the resolution. So you can do something like this:
int TextWidth = 45;
GUI.Label(new Rect(Screen.width-TextWidth, 10, TextWidth, 22), "Text");
The text you will appear in the upper right corner, regardless of the resolution.
Your answer
Follow this Question
Related Questions
How to clear a GUI Label 1 Answer
How to set text(timer) to a fixed place 1 Answer