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?
This post does not give enough information for a response. You should include some of the code that uses these variables and is showing up wrong, otherwise you will continue to be skipped over.
– VolureDarkAngeledited code to give example
– gardian06Unfortunately I was unable to produce the results you are getting. I run the game in unity as well as in standalone form and I get the exact same results either way.
– VolureDarkAngeladded image to show difference. both instances are the same code, but they are showing 2 different widths.
– gardian06What resolution does it say in the Stats, next to Maximize on Play in your game view? Because what it seems like is that you're designing for a larger resolution. I tested your code and it does the same clipping behavior on both Game view and Build @800x600. I also noticed the font is bigger in the build. Maybe an OS thing?
– Jamora