Hey guys, I am trying to build an Area that works with the screen width (so it adjusts to resolution), but the Area expands to the right instead of staying in the center and spreading out equally. Any idea of how to do this correctly?
GUILayout.BeginArea(new Rect((Screen.width/2), (Screen.height/2), Screen.height * (3f/5f), Screen.width * (0.5f/5f)), GUIContent.none, "box");
Thank you in advance!
Here, try this. Instead of using 3f/5f, try using a direct fraction.
GUILayout.BeginArea(new Rect((Screen.width/2), (Screen.height/2), Screen.width * 0.6f, Screen.height * 0.1), GUIContent.none, "box");
If you want the Rect for your Area to be perfectly centered at all times, do
aRect.center = new Vector2(Screen.width/2,Screen.height/2); GUI.Box(aRect,"CenteredBox");
Now you can edit aRect.width and aRect.height while keeping the Rect centered.