Unity resolution?

Hello. When I deployed my game, the GUI positions are messed up. I found the scene player resolution to be 970 by 640, how can I make the GUI work with different resolutions?

  1. Look into GUILayout which can reformat things nicely in many cases
  2. Get Screen.width and Screen.height and scale your GUI rectangles accordingly. You may want to just think in terms of 'fraction of screen width' and 'fraction of screen height'

In addition to what DaveA mentioned there's another very smooth method to do this and doesn't require you to recalculate the absolute position for every gui element. You can set the transform matrix for gui elements with GUI.matrix. So if you do this:

Vetor3 scale = new Vector3(origWidth / Screen.width, origHeight / Screen.height, 1);
GUI.matrix = Matrix4x4.Scale(scale);

where origWidth and origHeight is the screen size you used when designing the gui you can design you gui in the editor, using a good screen size (e.g. 1920x1200) using absolute positions like you would normally do. Then all you have to do is tell the script the original used screen size and will do the scaling for you. No extra code needed.

I think there was an example on how to do this in the platformer tutorial also.

Instead of hard coding your GUI elemts position, you can set the position according to the screen width and height(screen.width, screen.height).This way the positions wont get messed up. Hope this helps

make sure that you are not using free aspect in the player when designing as well. :)