- Home /
How to Center GUI On the Screen IOS
I am designing the main menu on a game i m working on but when I export to a device the position changes. How can i make it so it centers on the screen no matter what resolution the device is? Thanks!
Answer by Ericool · Dec 17, 2014 at 01:41 AM
use Screen.width and Screen.height
like so :
float myWidth = 100.0f , myHeight = 100.0f;
GUI.Button(new Rect( (Screen.width - myWidth) /2,(Screen.height - myHeight)/2,myWidth,myHeight) ) , "Hi");
Answer by zaid87 · Dec 17, 2014 at 01:45 AM
One way of doing it is to calculate the position after getting the Screen size;
position X = (Screen's width/2) - (object's width/2), position Y = (Screen's height/2) - (object's height/2)
this way it will always adjust itself based on the device's screen. You might also want to adjust the size of your object to follow the screen size instead by using calculations than just inputing number, so the screen will look the same regardless of device's screen size.
Your answer
Follow this Question
Related Questions
How to always have the mouse curser in the center of your game ? 3 Answers
How Do I Center A GUI Label? 5 Answers
GUI centering help 1 Answer
Aiming to center 0 Answers
Problem Trying To Get GUI.Label Centred 2 Answers