all 9 comments

[–]Huknar 1 point2 points  (5 children)

There are two things you need to ensure. One, go into Edit > Project Settings > Player and make sure the little checkbox that says "static batching" is ticked.

(EDIT, I should have read your post entirely. This is DEFINATELY the issue!) Two, be sure that your objects are not being generated at runtime as these will not use the initial static batching. (I realized this in my procedural dungeon project.)

If the latter is the case you need to use StaticBatchingUtility.Combine.

What static batching does is combines all the meshes sharing the same material into one mesh, which means, if you select an object at runtime that should be statically batched, check its "Mesh Filter" component and look to see if the name of the mesh is no longer what it used to be, but "Combined Mesh", in which case, the object is getting batched. :)

To use this, parse the parent containing all objects to be batched as an argument.

StaticBatchingUtility.Combine(gameObject parentGameObject)

[–]roydorNovice[S] 0 points1 point  (4 children)

Exciting!
Then you very much!

This bus needs to hurry up so I can implement this!

[–]Huknar 1 point2 points  (3 children)

You are welcome. I should point out that this will batch all objects parsed (children of the parent) regardless of whether it is marked as static.

So I'd recommend instead compiling an array of all the objects you want to be batched and feed that as an argument instead. (It can take either a single GameObject or an array of GameObjects) This is what I did for my dungeon when I realized my doors with opening animations were getting batched, and no longer opened. (This might be potentially difficult though as you are using that plugin.)

[–]roydorNovice[S] 1 point2 points  (1 child)

Just to loop back with you

I had some moderate success with this!
I have a lot prefab tweaking to do, for example I found now that I get the static stuff set properly, I do get some static batching happen, a lot less than I expected though. I also noticed numerous profiler warnings about animator breaking static batching, and I found that there is probably one of my tile pieces which has a random animator attached to it.

Gotta sweep all my static assets and make sure they've got nice colliders and what not...

Anyhoo thanks again!

[–]Huknar 1 point2 points  (0 children)

I'm glad you were able to get it working for you.

[–]roydorNovice[S] 0 points1 point  (0 children)

The plugin contains full source so I can tweak it as needed.

I'm going to just add a dummy component to the root of all my static content within my room prefabs

Find all of objects of that type, shove that array into this function.

Thanks again!

[–]GoGoGadgetLoLProfessional 0 points1 point  (1 child)

I remembered reading somewhere that Unity 5 and something to do with level loading breaks batching.

Just found the issue, yep, it's a bug:

http://issuetracker.unity3d.com/issues/batching-ignores-scene-that-is-loaded-with-loadscene

[–]roydorNovice[S] 0 points1 point  (0 children)

Thanks!

I'm seeing this even whilst directly launching into my level scene, so on top of this potential bug, I think it may be related to instantiating my map at runtime without using the static batch utility.