Closed ptbarnaby closed 2 years ago
That's a fantastic suggestion, thanks! I didn't know about StartAssetEditing. Even on my little test scene I can see 4x time improvement, and it's gonna be really helpful for large scenes. Just pushed, should be downloadable through the patcher: https://github.com/guycalledfrank/bakery-csharp/commit/3e285689ad6350aa61f4a125aa30e87f57270752
:)
On a reasonably simple scene I was seeing lightbakes go relatively quick but a long time spent after the lightbakes were complete before Unity would resume. This seems to go up with the number of mesh renderers in the scene rather than geometry complexity.
On investigation it turned out the majority of the time (about 128 seconds in my case) is spent in
GenerateVertexBakedMeshes()
and further that it was the call toAssetDatabase.CreateAsset()
taking up much of the time.After a quick google I found that wrapping the
GenerateVertexBakedMeshes()
call withAssetDatabase.StartAssetEditing()
andAssetDatabase.StopAssetEditing()
calls made it vastly faster (in my case 5 seconds). I'd recommend wrapping any bulkCreateAsset()
calls like this.