I have a game what I made in 480x320 resolution (I have set it in the build settings) in Unity. But I would like to publish my game for every Android device with every resolution. How can I do it, to tell Unity to scale my game up to the device's resolution? Is it possible to do?
Thanks in advance!
A easy way to do this is considering your target, I mean if you're doing a game for Iphone 5 then the aspect ratio is 9:16 v or 16:9 h.
   public float targetRatio = 9f/16f; //The aspect ratio you did for the game.
void Start()
{
   Camera cam = GetComponent<Camera>();
   cam.aspect = targetRatio;
} 
                        Here is my script for scaling the ortographic camera in 2D games
public float screenHeight = 1920f;
public float screenWidth = 1080f;
public float targetAspect = 9f / 16f;
public float orthographicSize;
private Camera mainCamera;
// Use this for initialization
void Start () {
    // Initialize variables
    mainCamera = Camera.main;
    orthographicSize = mainCamera.orthographicSize;
    // Calculating ortographic width
    float orthoWidth = orthographicSize / screenHeight * screenWidth;
    // Setting aspect ration
    orthoWidth = orthoWidth / (targetAspect / mainCamera.aspect);
    // Setting Size
    Camera.main.orthographicSize = (orthoWidth / Screen.width * Screen.height);
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With