I’ve just discovered a change between Unity 2 and 3 which has caused me a few hours headache.
I’ve been using hte following code to get the mesh from an object:
MeshFilter meshFilter= GetComponent(typeof(MeshFilter)) as MeshFilter;
Mesh thisMesh = meshFilter.mesh;
Worked fine but then stopped working when I tested with Unity3. When I checked the mesh the code returns it is huge, (About 150,000 verts instead of the 300 which is should be) further investigation showed it had been combined with other meshes in some way. Turns out there is a check box in ProjectSettings/Player to toggle StaticBatching and DynamicBatching and they seem to be on by default. Turning off Static Batching solved hte problem.
Now there are a few things I don’t understand:
- According to the manual this option is only available on Iphone OS but I don’t have that so why’s it there?
- I thought static batching only combined meshes with the same material but the objects I’m testing all have unique materials so how is it combining them into such huge meshes?
- when I turn of static batching it doesn’t seem to effect the frame rate - so what’s it doing?
- what does Dynamic Batching do? Didn’t seem to do anything when I turned it on or off
For now I’ve turned off both types ot batching but the manul seems pretty vague on this issue and it would be good to know what’s going on
regards,
Tony