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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question Scale with screen size, but for UI Builder viewport

Discussion in 'UI Toolkit' started by sasob8, Jun 26, 2023.

  1. sasob8

    sasob8

    Joined:
    Jul 11, 2017
    Posts:
    25
    I would like to have responsive scaling of ui elements on all resolutions.
    On UI toolkit Panel settings, you can set "Scale with screen size" (by default it is set to "Constant pixel size") just like in UGUI. But the problem is that UI Builder viewport doesn't match "Game view".

    For example if i compare resolutions: 2700x2000 vs 270x200 it should be the same (if "Scale with screen size" is turned on). And in game view it is, but in UI Builder viewport it is not. "Label" element is not scaled proportionally. I have turned on "Match game view" on root (uxml) element.

    ui-toolkit_scale.png

    On this image you can see that "Label" is not scaled with screen size, but red rectangle is. That is because red rectangle has size set in percentage, but if i set it as absolute pixel value it has same problem. If i set "Label" element to percentage value, it doesn't change anything.
    EDIT: i found old forum post where somebody from unity wrote that percentage for font size doesn't work yet. He also suggested that everything should be in pixel sizes (except where you need to have percentages), and scale everything with "Scale with screen size" option. Just like i did. But...

    It would be much easier to work if i could see final layout also in UI Builder viewport, so i can test different resolutions quickly.

    Am i doing something wrong?
     
    Last edited: Jun 26, 2023
  2. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    970
    Not sure if that's what you're looking for, but if you select the canvas in the UI Builder, there's an option called "Match Game View" in the inspector:

    2023-06-26 15_11_18-Window.png
     
  3. sasob8

    sasob8

    Joined:
    Jul 11, 2017
    Posts:
    25
    No it's not. Like i've said "Match Game View" is turned on. That doesn't help. UI Builder viewport and Game view does not match. You can see the image i have attached.