- Home /
Things to do to port game made for iOS in Unity to Android?
Hi! I have just made my first game for iOS and submitted it to app store. I was thinking of porting my game to Android also. I would like to know things one need to do/remember to port game made for iOS in Unity to Android. How to handle different screen resolutions and pixel densities, optimizations required, etc. Any other suggestions and important things you think I should know?
Answer by OpenSky · Mar 24, 2014 at 08:19 PM
-How to handle different screen resolutions and pixel densities ? -Simple, just transform the pixels in percents of the screen like this :
From :
if(GUI.Button(new Rect(Screen.width - 50, 2, 60, 50), optionsTexture, gui)) { Application.LoadLevel(2); }
To
if(GUI.Button(new Rect(Screen.width - 0.081f * xPos, 2, 0.078f * xPos, 0.078f * yPos), optionsTexture, gui)) {
Application.LoadLevel(2);
}
where xPos = Screen.width; and yPos = Screen.height. P.S: 1f xPos means 100% of the screen width, and 0.1f xPos means 10% of the screen width.
Answer by Adamcbrz · Mar 25, 2014 at 01:13 PM
Well this is a hard question to answer. Essentially if you didn't do anything ios specific then the port is pretty strait forward. There are some issues with texture compression but I will try and explain.
Texture Compression:
If you are using compressed textures then you have either have to rule out alot of devices or have a way to switch between the 3 different texture compressions. Well that is not entirely true. Let me elaborate. There are three different chip sets which support three different texture compressions ATC, DXT, and PVRTC. Now android has a fallback compression level that all chip sets are required to support, ETC. So you just might ask yourself why don't I just use ETC compression. And the reason is that the quality/file size is not as good. So that leaves you with three different texture compressions to handle all three devices. (I usually handle this by swapping between the textures/materials at runtime utilizing the SystemInfo.graphicsDeviceName to determine the chipset)
Screen Resolutions:
You can do the simple ways and add black bars for all device that don't fit the iOS standard resolutions. This is was something I saw more in the earlier days of android.
You can adjust the layout based on screen resolution and have a different layout for each screen resolution. This is probably a bad idea because it doesn't scale well and there are new devices all the time.
You can scale your interface to fit the screen. Where you place everything in a GameObject and scale the that gameobject depending on screen size. This approach is really easy to implement but can give pore results because it can cause stretching.
You can scale each item and position based on a percentage of screensize. This is what @OpenSky suggested. Honestly this is probably the best solution on most fronts.
There are other things to help optimize but they are dependent on problems. That is all I can think of right now.