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

Resolved UI Toolkit in Portrait Mode - Size Issue

Discussion in 'UI Toolkit' started by colourfoool, Mar 8, 2023.

  1. colourfoool

    colourfoool

    Joined:
    Jan 6, 2023
    Posts:
    2
    I am currently playing around with the UI Toolkit in Unity Version 2021.3.10f1, where I wanted to try out how it would work to make a UI for a mobile game.

    And I encountered a problem with the sizing of the elements when it comes to portrait mode, specifically with elements where the size is controlled by pixel-size. Normally, the UI in the UI Builder and the Game View look exactly the same, as can be seen in these two images:



    However, when I change the aspect ratio to Portrait Mode, the sizing in the Gameview becomes weird and the elements that have pixel values for their size become significantly smaller:



    I have enabled "Match Game View", so the Canvas Size should be the same.

    Does someone possibly know why it does that and what I could do to prevent that?
     
  2. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    529
    I think that you may lack space for your UI : you can change the scaling mode in the panelSetting to probably have a match with the reference width, or you can check the flex shrink/grow of your element.

    The UI Debugger can possibly help you with this
     
  3. colourfoool

    colourfoool

    Joined:
    Jan 6, 2023
    Posts:
    2
    Ah, thank you! That was totally the problem. I changed the Reference Resolution for the Scale Mode and now it works just fine!