- Home /
Batching problem when using multiple materials in one model
I have an fbx model that is using 3 different material for multiple meshes within the model. When I import the model into Unity, make sure the correct meshes are sharing the 3 materials, and check "Static" for the the parent model, I'm having inconsistencies in the batching. Basically, extra draw calls are being added to seemingly random meshes within the model, instead of the expected 3 draw calls (one for each material).
I went back into the model and exported each group of meshes per material separately into their own model files, and then imported those back into unity. When put back into the scene, the draw call count is correct at 3.
Does anyone have any idea why this would be happening?
Answer by Thomas Hentschel Lund · Jun 24, 2010 at 11:32 AM
This could happen if you have scripts that are manipulating materials. For example if you set the alpha channel of some item as part of a fade in/out.
When you manipulate a material this way, Unity creates a copy of the material into its own instance - and your link to the original material is lost = extra draw calls.
One way to get around that is to work on the shared material instead. BEWARE - changes here even done at runtime are persisted!! So you want to have some mechanism in place to revert any changes to your original material when start/stopping.