Reputation: 289
I am using unity for develope to my android phone. I am trying to develope a 2D game. When I put new image(sprite) in my game i can see it fully in unity but when I uploaded the game to my phone, parts of the image are missing from the sides. How can I fit the images sizes on all phones?
I saw the answer for this question but for eclipes java and not unity C#.
Upvotes: 1
Views: 2991
Reputation: 16277
That is it.
Now no matter how you resize the game view, your sprite can make best fit with it: either fit with the width or height, depending on the phone orientations and aspect ratios. In either case, however, you are guaranteed to see full image, rather than portion of it in your case. See the gif below:
Upvotes: 3
Reputation: 430
Use Screen.width
and Screen.height
to get the screen size of current device, then check your target phones screen aspect ratio:
For Window Phone, it's 5:3
and 16:9
iPhone: iPhone 3, 4 is 3:2
, iPhone 5, 6, 6+ is 16:9
Android phone has many types.
After you get the that, make sure your sprites are designed in exact ratio for your target phones, and it'll be matched with screen.
Upvotes: 0
Reputation: 1105
Screen.width
and Screen.height
are the only unity specific methods you need.
Pass in height, width, and position information to your objects based on your screen size.
The harder part learning the gui.
If you need more help with syntax, take a look at unit's gui documentation and tutorials.
Upvotes: 0