Search Unity

Question Android Aspec Ratio Issue?

Discussion in 'Android' started by JayArtist, May 26, 2021.

  1. JayArtist

    JayArtist

    Joined:
    Jul 1, 2014
    Posts:
    89
    Hi,

    I'm currently testing on Android, however I'm having a small issue with Screen Ratios.
    I want to create a game for Android and I'm assuming that the largest modern user base of devices would be 16:9 Landscape, 9:16 Portrait or there abouts (I'm not concerned with UI placement yet.)

    But, I realise like myself there are many users that have taller phones these days, such as mine which is 20:9.

    I built the apk with 9:16 for portrait and loaded it onto my 20:9 phone, however instead of the game scene being scalled down to fit the width and creating a letterbox effect on the top and bottom of the display (blue bars), the scene is full size top to bottom and off the screen on the sides!

    And yet when I rotate the phone to landscape, the game scene HAS blue borders on the side and full to the top as you might expect.

    I need the game to have blue bars at the top and bottom in portrait mode so that you can see all of the game. (Note: it's a little hard to see here, but there is red border around the game screen image, but cut off on the portrait image sides).






    This is what it should look like:


    What am I missing?

    Maybe I'm going about it wrong, but the game is a Breakout/Arkonoid style game and it has a frame around. Perhaps It's not built into Unity for this type of screen ratio layout?

    Cheers,

    Jay.
     
  2. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
  3. JayArtist

    JayArtist

    Joined:
    Jul 1, 2014
    Posts:
    89
  4. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    Aside from your UI fitting appropriately maybe look at this, I haven't tried it myself though and u probably would need to handle updating your rect at resize or orientation changes:
    https://docs.unity3d.com/ScriptReference/Camera-rect.html

    Also depending how you want the 3D world to scale, as far as I know, matching that is usually done via Field of View based on current aspect, but you will have to search for examples if that's what you need.
     
  5. JayArtist

    JayArtist

    Joined:
    Jul 1, 2014
    Posts:
    89
    As this is for a breackout/arkonoid style game, which is 2D, I'm not sure if this is relevant.

    The behaviour I was looking for is similar in the way in which photos are viewed on a phone. The image is scaled to fit (with borders if necassary) and does not go outside of the screen as it does in Unity. I'm starting to feel that Unity be default isn't made for this approach without coding.

    Unity appears to take the certical height of the game scene as a priority, not the overall game screen size with horizontal and vertical.
     
  6. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555