- Home /
list of features that are BAD for iOS (iphone)
Hey there Unity Answers... Is there a list anywhere (or do any of you have tips) of features to stay away from when creating games for the iPhone4? I've heard fog, excessive instantiation.... are there other things that people have noticed have been a problem.
Currently, my game runs at 200FPS on my mac, but slows down on my iPhone. I know it is far less powerful, which is why I'm casting a wide net to see what things i might have in my app that are drastically killing the FPS once on the device.
Thanks in advance!
(also side note: anyone know of a bit of code to use that would run on the device to show it's FPS as it's running)
Hey there, i added this code, and it seems to work, however the code itself seems to eat up a TON of FPS... is this due to the inherent slowness of onGUI elements?
The FPS you see using that snippet is closer to reality than what you see in the editor or simulator. It also doesn't use OnGui, it's just a guiText. It just adds 1 drawcall and some more text garbage collection.
$$anonymous$$ake sure to un-tick "Pixel Correct" on the GUI Text, this was causing a lot of slowdown for me.
Answer by azzogat · Jan 09, 2011 at 12:50 PM
This is really not a complete list, but off the top of my head:
The most important things to consider are your drawcalls. For example, an iPhone 3G really starts doing funky things over 25-30 drawcalls.
You could reduce your physics Solver Iteration count (from Edit> Project Settings > Physics) and use interpolation.
Try avoding instantiating / destroying objects. In some cases, implementing a GameObject pool might improve performance drastically.
Try to stay away from comparing strings and never use GameObject.Find .
Try to use Switch statements instead of many if / if else nested statements.
I also try to use extremely simple shaders. I usually blend all my external lightmaps and any other maps into the diffuse one and use a Texture Only mini-shader.
You should also try to stay away from using alpha-testing shaders if you're planning to release for the ipad. Due to it's high resolution and really boring hardware if has quite a few fill-rate related problems.
thanks for the tips! How do you recommend lessening draw calls?i currently have about 130 :/ what do you recommend ins$$anonymous$$d of GameObject.Find ? i have a few things that use gameObject.FindWithTag
Thanks again!
The most common way to reduce drawcalls is by using texture atlases and/or combining meshes.
FindWithTag is perfectly fine as it only looks through your tags (which are usually not that many) ins$$anonymous$$d of looking for a string in your scene.
I've been looking through some docs, and if I'm reading them correctly. Would it be better if i had one material, with all the parts on one texture? $$anonymous$$y situation is that i have cubes that are one texture, and action happens, their texture changes. Currently, i have one material assigned to all cubes, but reassign it's texture for the change. Would it be better to have the single texture, and change the offset to have the change occur? or am I completely missing the concept? - any chance of dynamic batching? i have one cube prefab with one material but currently, their textures are unique.
Every separate texture will add to your draw-call count. Depending on the size of your textures, it might be beneficial to use a sprite-sheet and scroll them when needed. Automatic batching will kick in when you have identical objects with the same material/ texture.
Any time you change anything in renderer.material (including texture offsets) it creates a material instance and definitely ensures that object will have its own draw call.. what you have to do is modify the UV's on the mesh, don't worry you can do this from script
Answer by Thom Denick · Jan 15, 2011 at 06:27 PM
Another big one that has not been mentioned is to avoid using GUI objects. Each GUI Object adds to your draw calls, but if you use 3D objects, SpriteManager, or EZGUI and SM2 instead (EZGUI and SM2 cost money), you can reduce your GUI draw calls significantly.
This Answer has some good info on reducing draw calls in a 3D Environment: http://answers.unity3d.com/questions/30419/reducing-draw-calls-vs-culling
Very in-depth answer on reducing Draw Calls: http://answers.unity3d.com/questions/7247/whats-the-best-way-to-reduce-draw-calls
Also for testing on iPhone and iPad, I think this is a great answer everyone should read: http://answers.unity3d.com/questions/9269/confusing-ipad-performance-problems-help
thanks for the tips. I'm still stumped though. :/ more on what I'm doing. I go through a for loop 120 times, and within it I run this. // var instance : GameObject = (Instantiate(myAsset, Vector3(transform.position.x + xAdjust, transform.position.y + yAdjust, transform.position.z), transform.rotation) as GameObject); // where myAsset is the cubePrefab that has the material with the texture atlas. I also set a random value on a variable on a script attached to that game object.
Answer by Jeston · May 06, 2011 at 09:21 PM
- Use vertex lit shaders instead of vertex colored on anything that doesn't fade
- Avoid large amounts of blended pixels: 2 particles close to cam is worst than 25 particles far away.
- Make motion framerate indipendent:
position += velocity * time; - Avoid anything thats non diffuse when possible
- Skybox shader is your friend
- Avoid clear on camera if the background hits every pixel
- (Design) Many smaller scenes > 1 long loading scene
- Use UnloadUnusedAssets()
- Use very few cameras / lights
- Batch draw sprites
- Triangle limit is ~ 15k
- Be smart with LOD's if you can afford the ram.
Answer by Mantas-Puida · Jan 28, 2011 at 11:42 AM
The best way to assess FPS and see what subsystem is "eating" most of your frame time is to enable built-in iOS profiler : http://unity3d.com/support/documentation/Manual/iphone-InternalProfiler.html
Answer by synapsemassage · Jun 26, 2011 at 03:06 PM
If you want precise answers you should read through the docs: http://unity3d.com/support/documentation/Manual/iphone-GettingStarted.html http://unity3d.com/support/documentation/Manual/iphone-performance.html http://unity3d.com/support/documentation/Manual/Reducing%20File%20size.html http://unity3d.com/support/documentation/Manual/Optimizing%20Graphics%20Performance.html http://unity3d.com/support/documentation/Manual/TroubleShooting.html#iPhoneTroubleShooting http://unity3d.com/support/documentation/Manual/Debugging.html
BTW it's absolutely possible to use GameObject.Find, but you should avoid it in Update functions. In Awake it's no problem at all. The built-in profiler is for Pro only.