Search Unity

How to lock screen ratio? Unity2d

Discussion in '2D' started by Faizan_poran, Jan 19, 2022.

  1. Faizan_poran

    Faizan_poran

    Joined:
    Jan 19, 2022
    Posts:
    1
    I started to develop a 2D platformer on Unity and I need the player to see only what falls in the 16:9 ratio, and the extra things are covered with black bars.
    Only what is in the white frame should be rendered. Page
    https://imgur.com/8bYQ3rd
    But when building on my phone with a wide resolution, there is extra view on the sides
    https://imgur.com/ZocqCiK
     
    Last edited: Jan 29, 2022
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    You can letterbox your game presentation.

    There are even assets on the asset store for this but I have not tried any personally.

    One easy way is to use two layered cameras, one for the main area of your game, the other to fill in the letterboxing.

    Another way involves using UI, if your game uses UI, and the AspectRatioFitter and other layout tools.

    Beware that certain walled-garden platforms may reject your submission if you letterbox with blackness. This is the case with Google Android TV for instance, and may be the case for others. Read the individual technical requirements for the platform(s) you target to see if there may be something more you need to do beyond letterboxing.

    Here are some notes on UI Anchoring, Scaling, CanvasScaler, etc:

    https://forum.unity.com/threads/inc...size-between-two-people.1130146/#post-7261747

    https://forum.unity.com/threads/game-ui-button-size-problem.1142650/#post-7337383