SpriteFactory.Sprite.SetMaterialOverride
C#: void SetMaterialOverride (Material material)
JS: function SetMaterialOverride (material : Material) : void
Description
Assign an override material and enable it. This can be useful if you need to switch materials dynamically without a predefined Material Set. The material's shader must have a _MainTex property to work. The material will be instanced for every atlas in the Sprite and the atlas texture will be assigned to the _MainTex property of the shader.
It is recommended that you make a Material Set in the editor instead of using a Material Override. Material Override incurs a draw call for each instance of this sprite on screen because the override material is instanced for each sprite instance. However, Material Sets are shared among instances of the same sprite and do not incur extra draw calls.
Note: The material displayed on the sprite in the scene view will always be from the first Material Set. When you press play, the sprite will be drawn with the custom material.
See Also
EnableMaterialOverride
DisableMaterialOverride
materialOverride