Static Batching and Runtime and Prefabs

Hi! I’m dealing with rather complex stuff, so not sure if I’ll get any help here, but I’ll appreciate any kind of input.

I am storing all the objects as prefabs, store lightmap data, and re-create them during runtime.
After manual assigment of lightmap data, I use

StaticBatchingUtility.Combine(this.gameObject)

and all works flawlessly.

But, scene loading times gorws very quickly with every new object, resulting in StaticBatchingUtility taking 13 seconds alone.

So i decided to store StaticBatchingUtility mesh too. In editor, I precalculate them mesh, and save it to the asset.

But, during gameplay, my models start to dissapear randomly and pop up back (I am using LODGroups);
But static batching works.

So, I am almost here, I have managed to bake lightmap, bake static batch mesh, but ended up with models popping up randomly. Is there something else I am missiing, when I am trying to sore mesh, created by StaticBatchingUtility inside asset, or this is a bug?

I see the same problem, if I use StaticBatchingUtility at runtime on some gameobject, and the instantiate this game object many times in a row; Seems like every prefab needs to have unique StaticBatchingUtility mesh, but essentially, meshes are the same. Hmmm… Maybe I also needs to clone mesh sharedMesh additionaly for every object, will check if it works.

Don’t mind this anymore, I see now that I was walking in circles. Long loading time comes up, because every batched game object needs separate mesh, which results in huge memory usage, which takes long to load. There is no magic cure to this.

Have static batching run on groups of meshes. Don’t continually run it on every mesh - run it on every mesh that is created within some XY bounding area. Inside the ZW bounding area, do a separate static batch. Yes, you’ll have two batches, but it’s lengthy because it has to create a new mesh, adding the new mesh into it. So if you have Mesh 1, 2, and 3, it’ll create a combined mesh of all 3. If you add a 4th, it’ll go through and create an entirely new mesh again, that includes the first combined mesh and the 4th mesh. And so on and so forth.

So the best way is to create 1, 2, and 3. And then to combine 4, 5, and 6. Or, that type of idea.

It’ll save on memory quite a bit if you do it that way.

On that note, I really want an asychronous or coroutine based static batching utility… it’s horrendously expensive anyways, and that’s not a fault of itself, but it is frustrating to not be able to time-slice it.

well

you can do it in a coroutine as you said batch 3 objects every frame
and do some loading screen while youre batching or dont do if youre doing it far from the player for streaming sake