- Home /
Best way to keep your game in the correct camera?
When I play my game in the unity editor it looks fine, but when I build it, depending on the size of the build the background will get cut off or blue space can be seen because the the screen isn't fitting just the background. Also the guis I set are always messed up, they fit perfect on the editor but on the build they're always in the middle of the screen, not how I want them.
So what's the best way to be able to keep your dimensions from unity editor to the final build.
Hi, first of all, about the GUI problem. The reason why it looks wrong in build with different resolution is because you probably used constant numbers for gui rect position. Something like this Rect(45,0,100,20), but ins$$anonymous$$d you should use Screen.Width and Screen.Height (which will read screen size), that will set the GUI position correctly, because you will set it up depending on screen resolution.
Unfortunately i didn't understand about the blue background problem, screenshot would be helpful.
Answer by Owen-Reynolds · Aug 21, 2013 at 06:06 PM
Use screen percents (0-1) to position and size GUI elements. Never use pixels. For GUIText(ures), this means to reset all pixelOffsets to 0, and size using transform.scale. Lots of places here to see how to do that for other things (such as GUI.Button.)
In the game Panel, set it to the same AspectRatio (16:9 ,etc...) as you will be playing it "for real." If you want it to run on two different ones (iPad and PC,) there's no setting that can ever help. You just have to make the game for both settings (black bars on the side, move menus ... .)