Hello.
I have difficult problem.
I am creating free roam game on iOS in the city.
I created 20-30 buildings prefabs, and duplicated them many times (about 2000). As far as I know, in Profiler’s Memory Tab, when I look onto “Meshes”, it should show that 20-30 count (because each prefab uses one mesh - prefabs are duplicated, but they still use same mesh). But instead, that stat in Profiler shows me that 2000 Meshes, which takes more than 500MB of Memory, which kills my app on iOS ;/
Can you tell me is there a way to reduce that number of used memory?
You’re trying to do too much for the target platform. You can’t just naively throw 2000 objects out and expect a phone to be able to handle it. There are going to be limits. You have to find some way to do less work. Make your world smaller or find a way load and unload the parts of the world the player is in. There are various things on the asset store that can help. See Sectr Stream and World Streamer.
Ok, but shouldn’t the prefabs work like I described? Why duplicating one prefabs multiple times takes so much mesh memory? Isn’t the prefab mechanism created exactly to prevent that?
Prefabs are going to save SOME memory but all those prefabs instances still have to be in memory and more importantly drawn. Also, you don’t say how you’re lighting the scene either so you’re probably not doing that efficiently.
Unity is a great tool for mobile game development but it’s not magic. You’ll need to learn more about Unity, the target platform and optimization if you want to be able to do an open world game on a phone.
About lighting - I disabled all real-time lights, I only have Baked lighting. So it shouldn’t take too much resources.
Thanks for those two packages you mentioned - I will definitely try them and see if it helps. Can you recommend which one from those two is better in your opinion?