Material (Instatnce) causes batching to fail

Record the reason for a static batching failure:

       Because the scene in the project involves discoloration, the method used is the same shader change, so you need to get the material change shader value. Then it led to the instantiation of a material as shown in the figure below 

This method of obtaining will result in a copy of the material for the instance, and the performance on FrameDebug is:

Said to have different materials.

To solve the idea, do not get the material to cause the instance material, the following two solutions:

1: Don't get the material through .material, use .sharedMaterial to get the material.

     Disadvantages: The change is the shader value of the resource file, that is to say, all objects that reference this material will be changed (the initial value must be re-assigned when re-entering the scene)

2: Through MaterialPropertyBlock (property block) to change, the specific operation is as follows:

       

 

Guess you like

Origin blog.csdn.net/LM514104/article/details/108254878