Class MaterialUtils
Runtime Material utilities
Namespace: Unity.XRTools.Utils
Syntax
public static class MaterialUtils : object
Methods
AddMaterial(Renderer, Material)
Add a material to this renderer's shared materials
Declaration
public static void AddMaterial(this Renderer renderer, Material material)
Parameters
| Type | Name | Description |
|---|---|---|
| Renderer | renderer | The renderer on which to add the material |
| Material | material | The material to be added |
CloneMaterials(Renderer)
Clone all materials within a renderer; IMPORTANT: Make sure to call UnityObjectUtils.Destroy() on this material when done!
Declaration
public static Material[] CloneMaterials(Renderer renderer)
Parameters
| Type | Name | Description |
|---|---|---|
| Renderer | renderer | Renderer that will have its materials cloned and replaced |
Returns
| Type | Description |
|---|---|
| Material[] | Cloned materials |
GetMaterialClone(Graphic)
Get a material clone; IMPORTANT: Make sure to call UnityObjectUtils.Destroy() on this material when done!
Declaration
public static Material GetMaterialClone(Graphic graphic)
Parameters
| Type | Name | Description |
|---|---|---|
| Graphic | graphic | Graphic that will have its material cloned and replaced |
Returns
| Type | Description |
|---|---|
| Material | Cloned material |
GetMaterialClone(Renderer)
Get a material clone; IMPORTANT: Make sure to call UnityObjectUtils.Destroy() on this material when done!
Declaration
public static Material GetMaterialClone(Renderer renderer)
Parameters
| Type | Name | Description |
|---|---|---|
| Renderer | renderer | Renderer that will have its material clone and replaced |
Returns
| Type | Description |
|---|---|
| Material | Cloned material |
HexToColor(String)
Convert a formatted hex string to a Color
Declaration
public static Color HexToColor(string hex)
Parameters
| Type | Name | Description |
|---|---|---|
| String | hex | The formatted string, with an optional 0x or # prefix |
Returns
| Type | Description |
|---|---|
| Color | The color value represented by the formatted string |
HueShift(Color, Single)
Shift the hue of a color by a given amount
Declaration
public static Color HueShift(Color color, float shift)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | color | The input color |
| Single | shift | The amount of shift |
Returns
| Type | Description |
|---|---|
| Color | The output color |
SetRenderMode(Material, MaterialUtils.BlendMode)
Set the render mode on the standard shader material. Adapted from StandardShaderGUI.SetupMaterialWithBlendMode
Declaration
public static void SetRenderMode(Material standardShaderMaterial, MaterialUtils.BlendMode blendMode)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | standardShaderMaterial | The material to apply the rendering mode to. |
| MaterialUtils.BlendMode | blendMode | The material rendering mode (opaque, cutout, fade, transparent) |