- Home /
Static mesh smooth, safe Unload ? 2018.1
I'm writing level-streaming system. Loading with
Application.backgroundLoadingPriority = low
is pretty smooth.
But
Resources.UnloadUnusedAssets() function is only way to unload everything SAFELY.
I've pretty large world, with lots of game object, LOD-groups cross-referenced materials and textures. Thats why :
Resources.UnloadAsset(something) can't be used with static. It's is ok with textures, acceptable, but if you try to unload Chunk A, and its static combined mesh, which consists of A and B chunk objects, objects in Chunk B will disappear.
Mesh.Combine() is bad idea cause of it breaks LOD-Group work, Isn't it?
Questions:
Is there way to combine static meshes ONLY INSIDE additively loaded scene? or
is there way to SEPARATE static meshes "per-object" (runtime?) ?
is there any way to TIME SLICE Resources.UnloadUnusedAssets()? AsyncOperation typical way doesn't help
Alternatives, to unload static meshes from memory?
Sorry for format, for some reason at unity answers I can't print new lines(
Yes, due to a change which was about half a year ago suddenly paragraphs are no longer seperated and bullet-point lists are not indented anymore. It's sad as it breaks all previously posted answers and questions as well. I still hope that they revert this change... some day.
I've posted 6k+ answers so i'm not going to edit them all ^^. The paragraph issues can be worked around by adding additional <BR>
tags. However the bullet point list issue is almost more annoying.
Answer by mitaywalle · Feb 13, 2018 at 01:31 PM
Just turn off static batching in settings
Performance impact wasn't so big. It was replaced with dynamic batching / GPU-Instancing
And no need to unload meshes. No generated chunks, only original meshes, which are lightweight and don't dublicate in memory after reload chunk.
Answer by Bunny83 · Feb 08, 2018 at 01:06 PM
Well, when you say "static" i guess you mean statically batched objects, right? It highly depends how you made those objects to participate in static batching. Note that once several objects are batched together you can't seperate them. The only way would be to destroy all objects that have been batched together and recreate those you want to keep. This of course isn't very useful.
However you said that you have "chunks" you want to manage. What you can do is to manually batch the objects you want to be combined at runtime using the StaticBatchingUtility. Of course if you load permade levels as "chunks" those shouldn't be marked as static. When you call StaticBatchingUtility.Combine it should have a similar effect as if the object was marked as static. However it should only combine the child objects / the objects you specify. Though i can't guarantee that it will work. You may want to do some tests.
Obviously the performance gain when you create smaller batching groups would be less than when having the whole scene batch together. Also calling Combine manually may decrease your "smooth transition" performance.
.
If the loading / unloading is too heavy you may want to split your world into several smaller scenes / chunks. Thanks to the multi-scene edit feature it should be easy to seperate a single scene into multiple.
Hello Bunny83. I've tried to not mark objects static and then use StaticBatchingUtility.Combine(), forget to write this in post. They unfortunatly combine with other objects, and if I destroy() / UnloadAsset() mesh where need, objects with same material disappear, where not need
Your answer
Follow this Question
Related Questions
Does Resouces.UnloadUnusedAssets frees asset bundles unused resources? 0 Answers
Issues with unloading textures and atlases 0 Answers
Does Unloadunusedassets unload unused assets loaded from Assetbundles? 0 Answers
reload texture after Resources.UnloadAsset() 0 Answers
Destroy single asset from AssetBundle 2 Answers