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.materialOverride

C#: Material materialOverride
JS: var materialOverride : Material

Description
Overrides the material on the Sprite.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.

This variable can be set in the inspector. However, to override the material during gameplay via scripting, it's recommended you call SetMaterialOverride instead. (The reason for this is that the change may take place 1 frame after assignment during gameplay by setting the variable, but the change takes place instantly when set via the aforementioned function.)

See Also
SetMaterialOverride
EnableMaterialOverride
DisableMaterialOverride