Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

UI changing when resolution changed

Discussion in 'UGUI & TextMesh Pro' started by S_George, Mar 24, 2019.

  1. S_George

    S_George

    Joined:
    Mar 14, 2019
    Posts:
    6
    Hello, i am making a 2d game.
    There i am using ui buttons to perform certain actions.
    In my engine everything looks fine, the ui button is placed at the top-left corner.
    Then the game is built and play the ui buttons are in different places (a bit to much in Y or X).
    Everything looks more horrible when playing it on different computer with different resoultion monitor.
    How do i fix that, the ui needs to be updated with the screen resolution size.
    (sorry for bad enghlish)
     
  2. dquek

    dquek

    Unity Technologies

    Joined:
    Apr 17, 2018
    Posts:
    70
  3. S_George

    S_George

    Joined:
    Mar 14, 2019
    Posts:
    6
    Hi, i am placing on UI canvas.
    Basically i want the UI stuff to update to the windows size
     
  4. TSabos

    TSabos

    Joined:
    Mar 8, 2015
    Posts:
    94
    If you want your UI to remain the same size relatively on screen no matter the resolution, change your Canvas Scaler to by Height and slide the slider all the way to the right to Height. When you make your UI make sure you properly use the Rect pivot and anchors and dont simply drag the objects from the center of the screen.
     
    shawnn10, systemicgames and YagoRG like this.
  5. moritzcerst

    moritzcerst

    Joined:
    Dec 6, 2020
    Posts:
    4
    You should change the UI Scale Mode of your Canvas to "Scale with screen size" and set your anchors to the correct position.
     
    RDelf and Karjalanpiirakka_Games like this.
  6. ASB

    ASB

    Joined:
    Nov 30, 2014
    Posts:
    2
    Hi, new reply, old question, possibly simple solution in newer versions of Unity (I'm using 2019.4.28f1 LTS). I found this after poking around a bit.

    Go to your canvas object and in the Inspector window > Canvas Scaler > UI Scale Mode > Scale With Screen Size

    Works for me. Hope this helps somebody. Here is an image also;

    uIFix.png
     
    nathanlam1wpi and ProGameDevUser like this.
  7. Daveheart

    Daveheart

    Joined:
    Mar 31, 2023
    Posts:
    5
    I'm having a similar problem, but what I need is the Screen Match Mode to be 0 normally, but be changed to 1 if a Fold phone is detected.

    I have no issue with the detection of a folding phone.

    The problem I have is finding the code or keyword I need to use to change "Screen Match Mode" to 1 when a Folding phone is detected.

    EDIT: Found my solution here: https://forum.unity.com/threads/canvasscaler-current-scale.285134/
     
    Last edited: Sep 15, 2023
  8. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,507
    This thread is on the wrong sub-forum as it's about UGUI not 2D. I'll move it for you.