I’m using the new UI system.
Everything looks perfect in the editor, but as soon as I build to iPhone, some of my elements are in the wrong position. The elements that are in the wrong spot are the ones that I control with a coroutine. I’ll tell the script to add 50 units to the position.x of a text element when I press the pause button. Looks great when I’m in the editor, but in the iPhone the text doesn’t move far enough. If I move it to the left, it doesn’t move far enough. If I move it to the right it doesn’t move far enough. Not sure what I’m doing wrong.
I suggest using the new Unity 5 Canvas System, and use Canvas scaler and choose setting > UI Scale Mode > Scale with Screen size.
If you still want to use the old OnGUI() then you need to work in % of the screen, which means, you need to devide your screen size by the needed amount, and fit it until its at the right spot.
Example: Screen.width / 0.5 = 50% so this will be always centered on the x axis.
If you are displaying the GUI through a script I had the same problem. Instead of setting the specific location for the GUI you need to set it so far from the center of the screen. This will help,
GUI.Box (Rect ((Screen.width / 2) - 100, (Screen.height / 2) + 200, 50, 50), “Text”);
It says the Box is 100 units left of the center and 200 units below the center of the screen. then it says the box will be 50 by 50 units and the Text that will be displayed in the box will be Text.
The problem is with the pivots. Go to the transform of the Text Gameobject in the inspector and you should see a box. Click the box and it should expand. Hold Shift and Alt at the same time than choose from all the boxes the position closest to where you want your button or text. Than when there are different resolutions it will always be where it should.
Hope this helps.
I figured it out, I need to use localPosition instead of position when I alter the text. I’m using a Canvas Scaler on the the Canvas.
if you got problem in GAME view you can unpress “gizmos” tab up there.