- Home /
Question by
Sadeq Rasheed · May 12, 2014 at 08:40 PM ·
guibuttonpixelsdevices
OnGUI BUTTONS differentscales on different devices
i added OnGUI buttons to my game but it scale changes on each device how can a stop that ? and make it one size for all devices ?
Comment
Answer by ninjapretzel · May 12, 2014 at 08:48 PM
If you're currently using absolute sizes, the button's won't appear where you might want them.
You might want to make them just take up a percentage of the screen, and use Screen.width/Screen.height when creating them.
Rect brush = new Rect(0, 0, Screen.width * .5f, Screen.height * .1f);
if (GUI.Button(brush, "This button takes up half the screen's width.")) {
//Do whatever
}
Then you can make buttons at any part of the screen:
//Make a rect in the middle center of the screen:
Rect rect = new Rect(Screen.width * .333f,
Screen.height *.333f,
Screen.width * .333f,
Screen.height * .333f);
GUI.Box(rect, "This is in the middle of the screen");
Your answer

Follow this Question
Related Questions
Button Turns Off and On Object 1 Answer
Button then instanitates gameobject 1 Answer
How to hook up the particle system to jump animation? 1 Answer
Make more buttons appear, on button click. 1 Answer
GUI Button Animation Cue 1 Answer