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

How should I set the aspect ratio in Unity when building a game for Android?

Discussion in 'Editor & General Support' started by UNTL1, Apr 8, 2020.

  1. UNTL1

    UNTL1

    Joined:
    Mar 30, 2020
    Posts:
    71
    I want my game to be played on phones in the vertical view. Currently the game is displayed within Unity in a horizontal 16:9 view, and thus I don't know how to arrange the elements within the scene yet. Also, I want to have the game play on full-screen even on taller ratios as some phones have, so how can you adjust the compatibility so the player character stays the same but enemies that are generated above the screen view still do that (plus something like adjusting their speed to the taller ratio while keeping their size relative to screen width the same)?

    Thanks in advance.
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,325
    In dropdown menu in Game window, you can select fixed resolution or fixed aspect ratio.
    upload_2020-4-8_17-3-22.png
    If a ratio you want does not exist, you can add it.

    Having said that, you're asking in a wrong forum.
     
    Joe-Censored likes this.
  3. UNTL1

    UNTL1

    Joined:
    Mar 30, 2020
    Posts:
    71
    What is the right forum for this?

    And if I want to make I game where the game is held vertically, I should put (for example) 1080*1920? This changes how it is rendered? And how would I make it adjustable to both that resolution and for example 1080 * 2340 like my phone?
     
  4. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,325
    YOu could try General Support:
    https://forum.unity.com/forums/editor-general-support.10/

    You should put whatever you need.

    It changes resolution and aspect ratio of the game camera that you use while playing the game in the editor. So you can playtest at a different aspect ratios.

    To make it adjustable, you'll need to avoid resolution-dependent logic. For example, you can determine size of view area through scripts, and a cheap option would be to add black bars for unsupported resolutions.

    Additionally, unity UI supports resizeable elements using anchors. This is covered here:
    https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/UIBasicLayout.html

    This won't help you with sprites, but it will allow you to make UI elements that will correctly position themselves on most resolutions.
     
    Midnightland likes this.
  5. UNTL1

    UNTL1

    Joined:
    Mar 30, 2020
    Posts:
    71
    What I look for is having the game full screen wherever it is played, with the adjustment being the upper end of the camera view being higher, the enemies being generated further away from the lower end of the screen (so they're still entering the screen from outside of it), and the enemy movement speed downwards being accordingly faster so it takes the same time to cross the length of the screen.

    The character and enemy sizes should remain the same relative to the screen width.
     
  6. peter_the_coder

    peter_the_coder

    Joined:
    Nov 28, 2017
    Posts:
    11
    If you want to get phone size(s) in the game view, it is easy, just select in File -> Build Settings -> under Platform either iOS or Android and than the button "switch platforms"
    Afterwards you have in the game view all kinds of phone resolution portrait OR landscape you can choose form

    Screenshot 2020-10-15 002812.png

    hope this helps for all other people who come here
     
  7. Fairyessfeli

    Fairyessfeli

    Joined:
    Aug 30, 2020
    Posts:
    6
    Yes! You did. :D:)
     
  8. Oleksii_Stetsenko

    Oleksii_Stetsenko

    Joined:
    Nov 1, 2021
    Posts:
    2
    Thank you
     
  9. ryanafsharryan

    ryanafsharryan

    Joined:
    Feb 24, 2020
    Posts:
    1
    Thanks friend