Sprite Factory

ReadMe
Release Notes
Overview
Using the Editor
Upgrading

Concepts
Sprites
Master Sprites
Sprite Groups
Colliders
Locators
Material Sets
SpriteUpdater
SpriteCamera

Advanced
Working in Multiple Projects

Classes
Runtime Classes

Videos
Overview
Creating Sprites
Sprite Inspector
Frame Events
Collision System
Locator System
Material Sets

Links
Sprite Factory Site
Web Documentation
Support
Contact

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