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

Fit game to all resolutions

Discussion in '2D' started by FakeMelon, Mar 27, 2018.

  1. FakeMelon

    FakeMelon

    Joined:
    Mar 20, 2018
    Posts:
    5
    Hello,
    I'm building an android game and I'm stuck at trying to fit my game to all the different screen sizes.
    After a lot of time messing with this, I came to understand that there are 2 issues here, one being the camera and the other one being the UI.
    The UI seems to be pretty simple to adjust, I use the canvas scaler to scale objects and anchors to make objects stick to the corners of the screen.
    But the camera issue gives me a lot of trouble. I tried to use something from the asset store to solve this, called Auto Letterbox which makes it so the game itself fits into any resolution by making black bars to fit the game to the whole screen.
    I got a few problems with this method. The first one is now some of the UI will appear where the black bars are but the most important issue is that I don't want there to be black bars. I want to fill those areas with my background which I can just make a really large one to fit all possible screens. Also, sometimes those bars will appear on the sides and I would like them to always go on top and bottom.
    The ideal situation for me would be that the game will keep its original aspect ratio and fill the whole screen's width while the parts left out on the top and bottom would be filled with my background which will just be there because it's way bigger than any screen on any device in the first place.
    Also, I might be wrong with what I think I need, so I would like to hear other suggestions.
    Thank you!
     
  2. jam-slc

    jam-slc

    Joined:
    Oct 18, 2016
    Posts:
    9
    It's because the camera's FieldOfView is a measuremeant of the vertical axis. So its fitting the camera view to the aspect ratio on the vertical axis. You can use camera.aspect to convert it to horizontal field of view.

    Try doing what the post at the bottom here says.

    Hope that helps!
     
    Last edited: Mar 27, 2018
  3. Natrad

    Natrad

    Joined:
    Mar 20, 2019
    Posts:
    3
    Hi,
    The same for me, hoping that tutorial will help you...

    Link:
     
    kiriakos37 likes this.
  4. Satindar

    Satindar

    Joined:
    Sep 11, 2020
    Posts:
    14
    @Natrad what is that voice
     
  5. AngryChiwawa

    AngryChiwawa

    Joined:
    Jun 18, 2020
    Posts:
    2
    If you want world space stuff to always be seen by the cam you could try cinemachine multi-object focus or whatever it's called.
     
  6. LookDev

    LookDev

    Joined:
    Dec 31, 2019
    Posts:
    4
    Watch the video you will get the solution:)-