Different GUI Sizes in player and on mobile??

I am working on an app for android and iOS and using the GUI functions extensively.
However, when I run the game in the Unity Player the GUI position is way off, but on the mobile devices they are positioned correctly.

examples:

Unity Player:
28875-guiunityplayer.png

Android: 28876-guiandroid.png

this is the code I used to generate the GUI in the preview images:

   void OnGUI() {
    		scrollPosition = GUI.BeginScrollView(new Rect(0,250,Screen.width,200),scrollPosition, new Rect(0,0,Screen.width,560),GUIStyle.none,GUIStyle.none);
    		
    		for(int i = 0;i < 50; i++)
    		{
    			GUI.Box(new Rect(110,50+i*28,100,25),"xxxx_"+i);
    			GUI.Box(new Rect(110+i*100,50,100,25),"xxxx_"+i);
    		}
    		GUI.EndScrollView ();
    	}

I would really appreciate it if someone could explain what I am doing incorrect. I have searched everywhere for a simple explanation of screen resolutions in Unity. TIA! :slight_smile:

Well,

it is a very common mistake, you need to use a relative position and size for your GUI elements.

Use the screen dimensions to adapt the size proportionnally.

example:

void OnGUI() {

            GUI.Box(new Rect(Screen.width/2,Screen.height/2,Screen.width/10,Screen.height/10),"I adapt to the screen resolution")
  
        }

I don’t know if the Box is well sized but it was just to give you the idea :slight_smile: