0
\$\begingroup\$

I need to position several UI texts on the screen.

I do this using a Canvas with Screen Space Overlay.

Also, these UI texts need to stay at their relative positions at different screen sizes.

Here is a screenshot in which the texts are highlighted in green:

enter image description here

One can see that they don't follow a grid-like pattern.

How could I keep them at their relative position at different screen resolutions?

Thank you.

\$\endgroup\$
  • 2
    \$\begingroup\$ Presumably you've studied up on the Basic Layout options Unity offers, including using anchors to position or scale something proportionate to its container, absolute offsets to position something at a fixed distance, and canvas scaling modes to adjust the scaling behaviour of the canvas as a whole? How have you tried applying these tools so far, and where do the results differ from what you want? \$\endgroup\$ – DMGregory Aug 19 '19 at 1:08
  • 1
    \$\begingroup\$ See also docs.unity3d.com/Manual/HOWTO-UIMultiResolution.html (Designing UI for Multiple Resolutions) \$\endgroup\$ – Tim Holt Aug 19 '19 at 16:52
  • \$\begingroup\$ @DMGregory Yes of course I have gone through the docs, and I've tried anything that came to my mind. I'm using your CamCrop script to keep my scene as I have designed it. I haven't found any way of anchoring the UI texts so that they would stay where they should. I will go through it again and post the various results. \$\endgroup\$ – tmighty Aug 21 '19 at 18:54
  • \$\begingroup\$ use scale with screen size in canvas inspector and set right place for anchors in the canvas. that is all. \$\endgroup\$ – virtouso Aug 21 '19 at 20:02
0
\$\begingroup\$

Place a Canvas on your scene. Add a Canvas Scaler to it and set "Scale With Screen Size". Add the UI texts to the canvas.

Make sure that the Anchors are set to "Center". (I had them set to "Top Left". That wrecked up the positioning at different screen sizes).

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.