- Home /
Adjust GUI in all Screens??????
Hello everyone, is there any way to adjust my GUI box in all screens? I mean when I change my resolution the box disappears.... please help me.
Please provide more information describing your exact problem. Is it a box you scripted yourself, eg. GUI.Box? If so, what Rect are you passing it? Are you using absolute coordinates for it, or calculating them based on the screen?
$$anonymous$$y box is like that: GUI.Box(new Rect(Screen.width 0.5 , Screen.height 0.965, healthBarLength, 20), "");
Answer by Briksins · Jul 22, 2013 at 09:38 AM
Just use Screen.width and Screen.height to define your box borders, that way box will be dynamically resided for various screens sizes for various platforms
//BOX SIZE DECLARATION
int width = <width_of_box>;
//if you want it to be full screen width then = Screen.width
int height = <height_of_box>;
//if you want it to be full screen height then = Screen.height
//POSITIONING BOX IN THE MIDDLE OF THE SCREEN
int x = Screen.width / 2 - width / 2;
int y = Screen.height / 2 - height / 2;
//GUI BOX DEFINITION
GUILayout.BeginArea(new Rect(x, y, width, height));
GUILayout.FlexibleSpace();
//***
GUILayout.Lable("Hello im GUI Lable");
//***
GUILayout.FlexibleSpace();
GUILayout.EndArea();
Thanks so much for the reply. How will be the health bar? I dont want it to be on the middle of the screen. I want it something like bottom-left or bottom right, or bottom-middle.
Thanks again :)
well it is your business to make decision where you want this box to be in the left or right and apply calculation logic in next 2 lines after this: //POSITIONING BOX IN THE $$anonymous$$IDDLE OF THE SCREEN
I just showed you an example how to use dynamic calculation of screens with different sizes
P.S. Also would be nice if you mark my answer as accepted if you happy with it, as it is good way to thanks people who helping you
Your answer
Follow this Question
Related Questions
Resizable GUI box how to? 1 Answer
Adjusting GUI 1 Answer
showing variables 1 Answer
know GUILayout current screen position 2 Answers
Application LoadLevel on Input.KeydownEnter TextField 0 Answers