- Home /
GUI cale and position according to the actual screen resolution.
Please help,how can I scale and position the GUI according to the screen resolution. GUI just changes the position and is located in some random position.HELP! Here is my script please help me:
function OnGUI()
{
GUI.Label (Rect((Screen.width / 2) - 38, 12, 140, 40), displayText);
GUI.color = Color.red;
GUI.Label(new Rect(Screen.width / 2 - 78, Screen.height / 25 - 12, 140, 40), "Time :");
}
Answer by HolBol · Jun 26, 2012 at 10:42 AM
Have you read how to use GUI.Label? This bit : (Rect(1,1,1,1)) in particular?
The first two numbers are the position. So in yours, that's where you've got
Rect((Screen.width / 2) - 38, 12,140,40)
So your (Screen.width /2) - 38 is your x position, the 12 is your y position.
The next two numbers are your scaling properties. One scales the x-axis, the other the y-axis of the label. Here yours is 140 pixels wide, and 40 pixels high.
And what do you mean by 'is located in some random position?' We need more information.
I set up the GUI and put where i need it, but when it increases the screen,it enclosed in a different place.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Player destroys when he touches particle effect. 1 Answer
Problems with scripts 0 Answers
Teleport enemy after player collides with an object? 0 Answers
animated sword + script 1 Answer