Unable to position Text according to Screen Size

First, I positioned the Text gameobject like this on the top right side of the canvas.

Everything seems okay when the screen isn’t maximized as shown below.

However when I press “Maximize on Play”, the Text of the Score has a weird position.

Any help would be much appreciated. Thanks.

1 Like

Hi Henry,

You could try anchoring the text element to the upper right side of the canvas (to do that click on the square that has red lines inside the Rect Transform component and change it from center/middle to right/top).

Let me know if that works. You can test by changing the aspect ratio of the game window, or detaching it and resizing it.

1 Like

Nice it worked!

But may I know why does the problem occurs?

1 Like

The anchor point basically tells you what part of the canvas the object is attached to. By leaving it in the center of the canvas, you’re telling Unity “I want this object to remain at this fixed position with respect to the center”. When the game window is resized, the canvas changes shape and size too, so the object changes position relative to the corners (but not to the center).

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms