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. Dismiss Notice

Question Problem with aspect ratios?

Discussion in 'Scripting' started by Sushant_Dhiman, Oct 8, 2020.

  1. Sushant_Dhiman

    Sushant_Dhiman

    Joined:
    Oct 1, 2020
    Posts:
    22
    I am building a 2D game. It is very good looking in 320 * 480 resolution.

    Screenshot = https://prnt.sc/uv8zdq

    But when I change to different aspect ratio my game screen get cutted from side and also gap gets added from top and down according to aspect ratio I choose.

    Screenshot = https://prnt.sc/uv946d

    How to make the canvas content and game content automatically resize according to screen size?
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,833
    Your Canvas is already resizing.

    The cuts on the side aren't pieces being taken out of the screen, they are showing where the boundaries of the screen are. You can't draw to those areas because they physically do not exist on the device that you are simulating. And the empty space at the top and bottom is there because your content has to become smaller in order to fit on a narrower screen.
     
  3. Sushant_Dhiman

    Sushant_Dhiman

    Joined:
    Oct 1, 2020
    Posts:
    22
    How to fix this?
     
  4. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,833
    What you have right now is what most people would consider "fixed" already. What is it that you want instead?

    You could probably make your content stretch to fill the available aspect ratio, but then it will look distorted.

    You could make your content size to the larger screen dimension instead of the smaller one, but then it will be cut off by the edge of the screen, so you won't be able to see the whole thing.

    You could make your game refuse to run at all on devices with aspect ratios that aren't close to your preferred one.