# GetMatrix

> Get a named matrix value from the shader.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## GetMatrix(string)

Get a named matrix value from the shader.

```csharp
public Matrix4x4 GetMatrix(string name)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the property.

### Returns

| Type                                                                  | Description |
| --------------------------------------------------------------------- | ----------- |
| [Matrix4x4](/engine/6000.0/script-reference/unityengine/matrix4x4.md) |             |

### Remarks

This is mostly used with custom shaders that need extra matrix parameters. Matrix parameters are not exposed in the material inspector, but can be set and queried with SetMatrix and GetMatrix from scripts.

Additional Resources: [Material.SetMatrix](/engine/6000.0/script-reference/unityengine/material/setmatrix.md), [Materials](/engine/6000.0/manual/materials-and-shaders/materials.md), [ShaderLab documentation](/engine/6000.0/manual/materials-and-shaders/shaders.md), [Shader.PropertyToID](/engine/6000.0/script-reference/unityengine/shader/propertytoid.md).

## GetMatrix(int)

Get a named matrix value from the shader.

```csharp
public Matrix4x4 GetMatrix(int nameID)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The name ID of the property retrieved by [Shader.PropertyToID](/engine/6000.0/script-reference/unityengine/shader/propertytoid.md).

### Returns

| Type                                                                  | Description |
| --------------------------------------------------------------------- | ----------- |
| [Matrix4x4](/engine/6000.0/script-reference/unityengine/matrix4x4.md) |             |

### Remarks

This is mostly used with custom shaders that need extra matrix parameters. Matrix parameters are not exposed in the material inspector, but can be set and queried with SetMatrix and GetMatrix from scripts.

Additional Resources: [Material.SetMatrix](/engine/6000.0/script-reference/unityengine/material/setmatrix.md), [Materials](/engine/6000.0/manual/materials-and-shaders/materials.md), [ShaderLab documentation](/engine/6000.0/manual/materials-and-shaders/shaders.md), [Shader.PropertyToID](/engine/6000.0/script-reference/unityengine/shader/propertytoid.md).
