I recently started working learning Unity2d from an iOS background. I am using the FWVGA Landscape (854x480) dimensions. I resized a 1136x640 background image (which I use for iOS) to 854x480 and made a sprite with the image but it only took a small portion of the screen. I had to resize the image in Unity. What are the general rules for converting dimensions from iOS to Android on Unity to get the dimensions to fit?
1136x640 is the ratio 16:9, as is 1920x1080 (1080p). Note a quick way to check the ratio: 16/9 = 1.77r. 1920/1080 = 1.77r. 1136/640=1.77r, 854/480 = 1.77r. All the same 16:9 ratio.
So, for Android phones that are also 16:9 you don't "need" to resize your assets unless say you want to up the resolution for quality sake on more powerful Android devices.
If you want to do it quick and easy then you want to draw your game in a camera at 1336x640 and then scale the camera view to match the resolution of the device you are running on (be it 1920x1080, 640x480, etc - all the same ratio).
You get problems with devices that are not 16:9 like tablets or phones that are say 16:10, 5:3, 3:2, or the iPads and Nexus 9 tablets at 4:3. This is a long subject though and there are lots of guides around to help. Try searching for "Unity 2d multiple screen ratios".
I think there are just too many variables to make this work "simply"
854x480 doesn't sound like a 'standard' HxW to me. and Unity is a 3D game engine which means its camera is on the Z axis when you are "looking down upon" a 2D game.
So the camera Z axis(Which apparently Unity tries to 'adjust' to match the phone's size, the phone's physical size, the size of the image you are using, etc. There are just a lot of variables. I would recommend https://stackoverflow.com/a/21375938 to see if that helps.
Related
I've Unity Plus and I'm trying to find out the optimum android splash screen size that fits all android devices as there's no option to specify multiple images with different resolutions for android.
So far I've tried 768x1024, 1536x2048 on every option(center, fill, fit), however some nexus tablets/phones won't display the splash image full screen correctly.
Is there an optimum/suggested image resolution/configuration for android devices that most likely fit all?
There is a Splash Scaling property in Player Settings for Android builds. Try setting it to Scale to fill (cropped). Your splash image will be scaled without changing the aspect ratio.
We are using 1280x720 image in Unity 5.3.4 for android builds without any problem.
The image will be cropped but if there is not any sensitive text or symbol on the edges that will not be a problem.
Hope this helps.
Generally, you'll want to include multiple copies of the image at different resolutions and aspect ratios in your deployment. For example, small and large, both with different ARs. You would read the screensize of the device and select the appropriate size image for the device.
To give more detail here, I worked on a game that targeted devices from small screen sizes (Galaxy Ace), to large tablets (Galaxy Note 10.1). We used our own splash screen implementation rather than unity's, and we calculated the aspect ratio of the device. We then checked the screen resolution. After that, we had enough info to select the appropriate resolution image for the screen. It costs a bit more space, but it looks nice and crisp on almost every device.
I am newbie to Unity 2D and creating a game in it. I wanted to run that game on almost all devices (Android, iOS, Mac, Windows and web. I am bit curious to see how Unity2D will handle this scenario and give the same user experience on various devices.
Also I noticed that I can preview my game in different aspect ratios. Is it the aspect ratio of the screen (like how the game would look on this type of screen) or of the camera (would look the same on all screens)? Do I need to provide different image resources based on the device's resolution?
Should I do something special to allow support for different resolutions, aspect ratios, etc?
Any help will be appreciated.
Aspect ratio management is explained in the following blog post: http://2sa-studio.blogspot.com/2015/01/handling-aspect-ratio-in-unity2d.html
Basically the orthographic camera has a size parameter which defines the half-height of the world area which will be rendered on screen.
Unity strategy is: fit rendered area height to screen height. Then the visible width varies depending on the screen ratio.
I'm developing a 2D puzzle like game. I want to target all iOS devices (iphone 4+ ,ipad 2+ and retinas) and as much android devices as possible. The problem is as you already guessed with resolutions and aspect ratios. How to deal with it, and what are the best practices. please share your experience and best approaches with this problem. My approach is , I'm building for 3:4 (the game is in portrait mode) aspect ratio with ipad retina resolution images and using orthographic camera. for different aspect ratios i resize orthographic camera , and as expected I get black bars at the top and bottom . aka pillarbox. so I'll just resize (scale Y) the main scene. (drop everything in an empty gameObject and scale it up). or add 2nd camera to deal with this black bars. But I need the best and the most correct way to deal with this problem , what's the best practices for 2D game development when targeting multiple resolutions,aspect ratios. I've searched the net and forum but couldn't find the CORRECT WAY.
Right now my game is using direct x and y values. I realized that my the S3 was scaling my images double size along with some other size inconsistencies between devices. I read around and learned a bit about android dpi and scaling and stuff.
I'm wondering whats the correct way to do locations and stuff so that it takes into account different screen sizes.
I'm thinking it can be done by setting a target dimension and then scaling all positional values according to the ratio of the target dimension to the actual screen size.
I also read somewhere that you can draw onto a buffer and display that buffer stretched to the screensize, however for this method would android's auto resizing affect the drawn bitmaps?
Thanks
The idea is to use aspect ratio, android auto resizing to your benefit. Every android screen has its own aspect ratio, your game should use the aspect ratio and fill blackborder where ever there is a need to fill space on the screen. So use appropriate root layout fitting attributes.
Android resizes drawables automatically that dont fit. So if you keep only 1 set of drawables, the resizing work for Android increases and it uses Bitmap's internally to do the resize. More the bitmaps more the memory utilization, more the cleanup, more the GC and slower your game. So the best practice here is to create different dpi different image sets to use.
To start with I suggest that you purchase 3 phones, samsung y (small screen), samsung s2 (good screen) and a tab 7 or 10 inch. Copy your original drawables to all the folders, just to get a feel of the game and to eliminate all memory issues. Once your game works nicely, smoothly without any memory issues on all the phone sizes, just walk into a graphic designers office and show him how bad your game looks on some phones. He will create graphics that will work for that dpi.
Its a game of intelligent drawable resolution, sizing and A WHOLE LOAD OF TESTING :).
Hope this has helped.
Edit : Read my answer in memory issues
I'm writing a game specifically for Android tablets, using andengine. If I use fixed camera,
andengine will scale the view to fill the device screen. What values I have to use for CAMERA_WIDTH and CAMERA_HEIGHT, so that the game will work fine on most popular tablets?
Thanks.
I think you should consider writing for a particular size - say a 7" tablet - the Nexus 7 has a resolution of 1280 x 800. Then let AndEngine use a RatioResolutionPolicy to adjust for the differences in any other screen sizes. See this answer for more info
Sprite size on different screen size Andengine Android