- Home /
Game Crashes on iphone3gs and iPod touch but work fine on iPhone 4s
Hello my game is crashing on iPhone 3gs,iPod.I am using 400 textures of 2048*32 because its a 2d game.I think its the out of memory issue as far as i have searched but for now i need a professional advice that what should i do now.
Answer by flamy · May 08, 2012 at 11:40 AM
Hi Haider,
This is some common problem faced by most 2d mobile developers. I can give you few advice that may help you.
First of all don't declare Texture objects in script and swap textures when needed. Instead you have to use Resources.Load() function, In this case you will only be loading what you want not everything. And don't get decided by the VRAM size in Stats screen of editor, instead use profiler to check ram size. Since this is a 2D game there are chances that lots of Texture2D objects reside in memory. Because 400 textures is big for any device to handle.
And if you are following the above step don't forget to call Resources.UnloadUnusedAssets() when ever possible to keep the memory in check. Also you should note that this function would cause a jerk when called.
In project setting remove the anisotropic option, if it is not perspective camera. and also set all texture's aniso level to the minimum.
Also avoid True color images when ever you can. I know in 2d game it is a hard decision but try to compromise for objects that doesn't grab attention.
if the game has online features make sure that you wait for all the downloads before using the downloaded data, this is because the speed in 4G and 3Gs varies.
PS : if you are drawing it with OnGUI() try to enclose the whole rendering call inside a if loop looking like this
if(Event.current.type==EventType.Repaint)
{
// all drawing
}