Class MaterialUtils
Runtime Material utilities.
Inherited Members
Namespace: Unity.XR.CoreUtils
Syntax
public static class MaterialUtils
Methods
AddMaterial(Renderer, Material)
Adds a material to this renderer's array of 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 add. |
CloneMaterials(Renderer)
Clones and replaces all materials assigned to a Renderer
Declaration
public static Material[] CloneMaterials(Renderer renderer)
Parameters
Type | Name | Description |
---|---|---|
Renderer | renderer | Renderer assigned the materials to clone and replace. |
Returns
Type | Description |
---|---|
Material[] | Cloned materials |
Remarks
Warning
You must call Destroy(Object, Boolean) on each cloned material object in the array when done.
See Also
GetMaterialClone(Renderer)
Clones and replaces the material assigned to a Renderer.
Declaration
public static Material GetMaterialClone(Renderer renderer)
Parameters
Type | Name | Description |
---|---|---|
Renderer | renderer | The renderer assigned the material to clone. |
Returns
Type | Description |
---|---|
Material | The cloned material. |
Remarks
Warning
You must call Destroy(Object, Boolean) on this material object when done.
See Also
GetMaterialClone(Graphic)
Clones and replaces the material assigned to a Graphic.
Declaration
public static Material GetMaterialClone(Graphic graphic)
Parameters
Type | Name | Description |
---|---|---|
Graphic | graphic | The Graphic object assigned the material to clone. |
Returns
Type | Description |
---|---|
Material | Cloned material |
Remarks
To use this function, your project must contain the Unity UI package (com.unity.ugui).
Warning
You must call Destroy(Object, Boolean) on this material object when done.
See Also
HexToColor(String)
Converts an RGB or RGBA formatted hex string to a Color object.
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. |
Remarks
The hue value wraps around to 0 if the shifted hue exceeds 1.0.