I have a TextMeshPro GameObject, which I placed within the Canvas. The canvas is set to Scale with Screen Size
and has a reference resolution of 1440x1080.
The TextMeshPro GameObject is anchored to the top-right and its position horizontally is -185 from the anchored point (top-right). And within 1440x1080 resolution it looks like:
But when I make my Display resolution higher or smaller (like for example 1920x1080 as in the image below), the TextMeshPro GameObject goes outside game and ends up in the black area.
I tried changing the position of TextMeshPro GameObject via a script attached to the canvas. I came up with the following formula but it seems wrong.
DisplayResolution.x - (DisplayResolution.X + (ReferenceResolution.X - TextMeshPro.Location.X))
Assuming:
DisplayResolution.X
= 1920
ReferenceResolution.X
= 1440
TextMeshPro.Location.X
= -185
Edit - answer to comments:
Where Starry Backfield is at:
Camera settings:
Canvas Settings:
Size
is set to12
and it has aTransform.Position
of x=12 and y=9. However, the Reference resolution of the Canvas is set to 1440x1080 which also is 4:3. I updated the question and added an image with an arrow where the starfield backdrop is drawn. \$\endgroup\$