in my game I am setting my GUI to display to the screen so that resolution does not matter. I have done all of my initial setup work based on 800X600, but instead of just constants I am first setting universal constants based on resolution, and then just doing math based on that. for example:
void OnGUI(){
float width = Screen.width/8; float height = Screen.height/6;
float wSpace = width/10; float hSpace = height/10;
GUI.Box(new Rect(width*2+wSpace*2, height+hSpace*2, width*2+wSpace*2, height),
"welcom here is some text that will" + '
’
+ “show up @800X600 in the GameView,” + ’
’
+ “but in a build it will be clipped off,” + ’
’
+ “and the window will be pinched”);
}
this way I can just run through and set all of my Rects based on multiples/addition/subtraction, of these instead of calculating hard numbers for each thing, and then when the resolution changes having nothing work right.
this all works perfectly in Editor/GameView, but when I do a build, and open the build at the target resolution nothing matches what I had set.
- text boxes are pitched
- buttons don’t line up
- things are clipping through boxes, groups, and screen boundries
I can maybe see instances why at lower resolutions these calculations don’t particularly work, but why at the target resolution that I am checking against is it inconsistent between Editor/GameView, and Build?
Edit corrected incorrectly copied division of contants
adding picture:
running the same code. left is build right is GameView how are these different then?