- Home /
Question by
Borzi · Oct 13, 2013 at 11:21 AM ·
screenguilayoutareascreen.widthscreen.height
Make area adapt to screen size
Anybody know how to do this?
I made my own attempt but it doesn't seem to to work:
GUILayout.BeginArea(new Rect((Screen.width/2) - Screen.width * (0.5f/5f), (Screen.height/2) - Screen.height * (0.5f/4.0f), Screen.height * (3f/5f), Screen.width * (0.75f/5f)), GUIContent.none, "box");
Comment
What exactly are your trying to do? Where should the Rectangle be on screen, and how big should it be?
I answered it. I was trying to make a square in the middle (or near it) and have it adapt to very resolution. I don't know why this did not work before.
Best Answer
Answer by Borzi · Oct 13, 2013 at 12:15 PM
GUILayout works a bit weird, but this has been successful for me (I have no idea why though):
GUILayout.BeginArea(new Rect(Screen.width/3, Screen.height/2.7f, (Screen.width) - (Screen.width/1.5f), (Screen.height) - (Screen.height/1.5f)), GUIContent.none, "box");
This adapts perfectly to the screen. I don't know why the other one doesn't.