Class StencilMaterial
Dynamic material class makes it possible to create custom materials on the fly on a per-Graphic basis, and still have them get cleaned up correctly.
Inherited Members
Namespace: UnityEngine.UI
Assembly: UnityEngine.UI.dll
Syntax
public static class StencilMaterial
Methods
Add(Material, int, StencilOp, CompareFunction, ColorWriteMask)
Add a new material using the specified base and stencil ID.
Declaration
public static Material Add(Material baseMat, int stencilID, StencilOp operation, CompareFunction compareFunction, ColorWriteMask colorWriteMask)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | baseMat | The base material. |
| int | stencilID | Stencil reference value. |
| StencilOp | operation | Stencil operation on pass. |
| CompareFunction | compareFunction | Stencil comparison function. |
| ColorWriteMask | colorWriteMask | Color channel write mask. |
Returns
| Type | Description |
|---|---|
| Material | A material with the requested stencil settings. |
Add(Material, int, StencilOp, CompareFunction, ColorWriteMask, int, int)
Add a new material using the specified base and stencil ID.
Declaration
public static Material Add(Material baseMat, int stencilID, StencilOp operation, CompareFunction compareFunction, ColorWriteMask colorWriteMask, int readMask, int writeMask)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | baseMat | The base material. |
| int | stencilID | Stencil reference value. |
| StencilOp | operation | Stencil operation on pass. |
| CompareFunction | compareFunction | Stencil comparison function. |
| ColorWriteMask | colorWriteMask | Color channel write mask. |
| int | readMask | Stencil read mask. |
| int | writeMask | Stencil write mask. |
Returns
| Type | Description |
|---|---|
| Material | A material with the requested stencil settings. |
ClearAll()
Releases all cached stencil materials and clears the internal cache.
Declaration
public static void ClearAll()
Remove(Material)
Remove an existing material, automatically cleaning it up if it's no longer in use.
Declaration
public static void Remove(Material customMat)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | customMat | The stencil material to release. Destroyed when reference count reaches zero. |