I took images from my iOS game that I am developing in SpriteKit and put them in a Unity Android 1136x640 screen, which are the same dimensions for the iOS game but the images are a lot smaller. How can I get a similar representation that coincides with the screen size? I would like a 284x640 image to be displayed to take a quarter of the screen width, which is what happens in reality.
There are several things which affect sprite scaling in Unity.
- When you import a sprite in Unity, there is a setting Pixels per unit for the sprite asset in your project folder structure. Use this setting to scale the sprite.
- All Game objects have a Scale X, Y and Z in their Transform-component which makes them larger or smaller. Note that the scale of a parent game-object also affects all of its child-objects.
- When your camera is set to Projection: Orthographic, then the property Size defines how many units fit on the screen.
- When your camera is set to Projection: Perspective, then objects closer to the camera will look larger than those further away. The Field of View also allows you to control the zoom factor.
When your camera is orthographic, then the vertical height of the viewport in Unity units is twice the camera size. That means to get 1 px image = 1px on screen, set the Pixels per unit to your vertical screen resolution divided by twice the camera size.
When you have a camera size of 5 (default) and you target a 640px high display, set the ppu to
640 / (5 * 2) = 64.
You might also want to set the Filter Mode of your images to "Point (no filter)" to avoid sprites getting blurred when their positions are not perfectly on-pixel.
If you select your image and make sure it's set as a sprite, you'll notice an import property called pixels per unit. Changing this will change the scale of your sprite. There are other factors though, such as the camera settings. It sounds like what you're looking for is pixel perfect rendering. Here's a good resource for that: http://blogs.unity3d.com/2015/06/19/pixel-perfect-2d/