Search Unity

Unity UI Scale With Screen Size Not Working With Aspect Ratios

Discussion in 'Editor & General Support' started by qiveal, Apr 13, 2022.

  1. qiveal

    qiveal

    Joined:
    Jan 31, 2022
    Posts:
    320
    For reference I am using scale with screen size in my canvases I also double checked and I'm using the correct resolution. I have tested it looks like everything is anchored correctly, so my problem is that when I change aspect ratios if a aspect ratio is a little bit shorter than my UI will run off the top and bottom of the screen. It's not scaling at all, please help.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
  3. qiveal

    qiveal

    Joined:
    Jan 31, 2022
    Posts:
    320
  4. chetan312

    chetan312

    Joined:
    Mar 12, 2017
    Posts:
    15
    Hii, same problem .Do you find any solution ?
     
  5. CodeRonnie

    CodeRonnie

    Joined:
    Oct 2, 2015
    Posts:
    531
    Here is my old post on the subject: https://forum.unity.com/threads/und...n-match-mode-and-reference-resolution.524194/

    It's as Kurt said in his linked post. Scale with screen size, match height 100% for landscape. The axis and concepts change to width of you're making a portrait mode app. For me, it makes the most sense for your reference resolution to represent the most narrow aspect ratio you expect, like 4:3 or even 5:4 to be extra careful. The height in pixels should be a common resolution you would expect, that won't scale too much up or down between various screens. The numbers you type in the rect transform are all in relation to the reference resolution. So, for a reference height of 1080, typing a height value of 108 will always be 10% of the height of the screen, on any resolution. Anchors on the height axis don't actually matter all that much in this configuration. Width values are in relation to the reference as well. Except, if you design from the most narrow aspect ratio, then your elements will spread out with the extra pixel space on wider resolutions. This solves your issue of elements running together on narrow ratios. Design for those narrow ratios in editor, and expect everything else to spread out from there. That's where anchors on the horizontal axis come in, if you want elements to stretch out horizontally on wider ratios, and to decide what part of the screen horizontally they grab onto as they spread out.