Very long playmode enter times with moderately complex nested prefabs

For example, I have a building prefab that contains about 100 highpoly (~10k tris) prefab variants, each containing 3-6 LOD levels. Placing it around a few dozen times already increases the playmode enter time to a few minutes.

How can I optimize this better?

Hi, we need a bit more information to help you.
First of all, which exact version of Unity are you using? You can see that in Help → About Unity

Then, can you use the profiler to take a sample? You need to enable Deep Profile, set Profiling mode to “Edit Mode” and hit play. Then stop the capture as soon as its in playmode and save the capture.
You can attach the file here and/or post a screenshot of it.

@Peter_Olsted I was using alpha9 before but now i updated to a13 and the time has come down significantly (40-60s), especially when exiting (15-20s). But there is still a significant stall that probably shouldn’t be there. I attached the screenshots. I didn’t attach the profiler data because it is very large.

Interesting numbers you got there. Could you create a bug report for your project? We would like to take a closer look at it.
Unity QA: Building quality with passion has all the details

I made a report.

Hey @Win3xploder , from the profiler snapshot you shared above it looks like physics took 24% of the frame for baking ~1800 meshes. Does this sound about the right order of magnitude for the meshes to you?

In the meantime, I’d add a few thoughts.

(1) Even if you need to bake this many meshes, the problem shouldn’t affect the built player load time – since hopefully you have mesh pre bake enabled in the settings (offsets bake costs to build time).

(2) Do you really need this many meshes at start? Maybe some could be prepared later? E.g. is it possible to prepare LODs on demand as opposed to baking all 6 at the play mode enter time? A benefit of doing the load manually is that you can use Physics.BakeMesh from a C# job on multiple threads on these meshes (split costs among cores).

(3) If nothing helps, and you do need scale, I’d probably make something like a set of asset bundles with the baked meshes really. Not super cool if you need to change LODs often, as you need to rebuild it after any change – but at least it will boost your regular iteration times.

(4) I noticed that the scaled meshes are being built. Could it be that in fact their a few basis mesh variants but then there is a wide variety of scaling applied? Scale can sometimes be tricky and prevent the baked physics mesh from being shared. Could be inspiring to read docs for Physics.BakeMesh, where it talks about the sharing rules.

Anthony.
Hope that helps

Cool, thank you very much Anthony! I’ll check these things once I have time!