- Home /
Button and resolution problem
Hello I have a big problem. button change place after a build the project and change the resolution. in unity i work with 1200 * 700 resolution (( 16/9 )) but when a change other resolution or make it iu full screen the button change place. not the same when i put it in unity project. how can i fix that . thanks
Jeez, I with people would learn how to use the SEARCH field. This question is asked about once a month!
Answer by StephanK · Aug 26, 2010 at 12:35 PM
GUI positions are absolute meaning that they will change their relative position if the screen size changes. To make them relative you need to calculate your Rectangles using factors. eg.:
void OnGUI () { public float x, y, width, height; Rect pos; pos.x = x * Screen.width; pos.y = y * Screen.height; pos.width = width * Screen.width; pos.height = height * Screen.height;
GUI.Button(pos, "test"); }
With x, y, width and height being values between 0...1 this should lead to relative positioning.
How can i apply this script. i have many button in my game . should i integrate this script with script of all the button or how. thanks
Your answer
Follow this Question
Related Questions
GUI Button sound problem, don´t work 1 Answer
full screen and resolution 1 Answer
problem with gui??? 0 Answers
Tooltip does not show 1 Answer