Ivan
Ivan

Reputation: 1851

How to make game fit screen on Unity

I'm developing a game, and in Unity I've set the resolution to 1280x800. When I export to Android, I expect it to adjust to the screen (adding black bars if necessary) but it isn't the case.

This is how it looks like on a Nexus 4: Game on nexus 4

And on a Nexus 5: Game on nexus 5

How can I make it so that it looks the same everywhere? (having black bars if necessary as I said before).

Upvotes: 1

Views: 2471

Answers (1)

Esa
Esa

Reputation: 1666

You need to normalize the camera's orthogonal size to a wanted resolution:

camera.orthographicSize = 640/screenwidth * screenheight/2

More info here

Upvotes: 2

Related Questions