I’m running into an issue where Unity will crash if I remove meshes anytime after the StaticBatchingUtility has touched them. My meshes have to be streamed in and out as needed to keep memory usage low, but I’d like to take advantage of static batching if possible. Steps as follows…
- Stream in mesh (Resources.load mesh and apply it to meshfilter.sharedMesh),
- Run static batching on objects that have streamed in meshes.
- null out the meshfilter.sharedMesh of the objects.
I’ve also tried calling StaticBatchingUtility again after the meshes are removed, but that doesn’t seem to work either. Any ideas what might be going on?
I figured out that Unity will crash unless you turn the renderer off after removing the mesh reference.
Now I have a new problem with the meshes not showing up again after they’ve been combined, removed, and then added back into the scene. Anyone have any luck streaming meshes in and out of their scene and getting the static batching utility to work?
Holy necro Batman! Sorry to exhume this 11-year-old post, but I have the exact same question today and maybe there are better answers now. (Or answers at all!)
To recap: once I’ve added a mesh to a batch using StaticBatchingUtility.Combine, how can I remove it? Even if I have to tear down the entire batch and re-combine everything but the one mesh I want to move, that’s OK. This will be a rare event. But is there any better way?
1 Like