1
votes

I added a sprite with a PNG image to a 16:9 scene in Unity. When I view the scene on the iPad (4:3 aspect ratio) it appears distorted. How can I make the sprite maintain it's proportion?

The image on the iPad:

enter image description here

On the computer (in Unity):

enter image description here

Here are my settings.

enter image description here

I tried using this script for the camera but it didn't work it just enlarges the character and it was still distorted. (source):

using UnityEngine;

public class PixelPerfectCamera : MonoBehaviour {

    public float pixelsToUnits = 100;
    private Camera camera;

    void Awake () {
        camera = Camera.main;
    }

    void Update () {
        camera.orthographicSize = Screen.height / pixelsToUnits / 2;
    }
}

I am using the sprite in a 2D scene using Unity 5.

2
Can you add a snap of what image looks like on both screen resolutiosnUmair M
You need to adjust the camera ortographic size based on the resolution. This is what you need youtube.com/watch?v=yI8JrBNTwkcFiffe
@UmairM Just added a picture.Idan Shechter
@Fiffe I tried this one, didn't work: frispgames.com/…Idan Shechter
@Idan Shechter There's a lot of Pixel Perfect camera scripts on the internet and even on the asset store, you probably got the outdated one or did something wrong.Fiffe

2 Answers

2
votes

You can use preserve aspect option of the image. enter image description here

0
votes

You are using the sprite on a UI/Image which requires a rect transform component resulting it resize according to screen. Use sprite renderer on empty object.

One way to create this is using menu:

GameObject->2D Object->Sprite

Hope this helps