# uv4

> The texture coordinates (UVs) in the fourth channel.

## Definition

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

```csharp
public Vector2[] uv4 { get; set; }
```

### Remarks

This channel is also commonly called "UV3". It maps to the shader semantic `TEXCOORD3`. When you call [Mesh.HasVertexAttribute](/engine/6000.7/script-reference/unityengine/mesh/hasvertexattribute.md), this channel corresponds to [VertexAttribute.TexCoord3](/engine/6000.7/script-reference/unityengine/rendering/vertexattribute/texcoord3.md).

Unity stores UVs in 0-1 space. \[0,0] represents the bottom-left corner of the texture, and \[1,1] represents the top-right. Values are not clamped; you can use values below 0 and above 1 if needed.

This property is supported for backwards compatibility, but the newer [Mesh.GetUVs](/engine/6000.7/script-reference/unityengine/mesh/getuvs.md) and [Mesh.SetUVs](/engine/6000.7/script-reference/unityengine/mesh/setuvs.md) functions allow you to access the same data in a more user-friendly way, and use a Vector3 or Vector4 value if you need to.

This property returns a copy of the data. This means that it causes a heap memory allocation. It also means that to make changes to the original data, you must update the copy and then reassign the updated copy to the mesh.

The following example demonstrates how to create an array to hold UV data, assign texture coordinates to it, and then assign it to the mesh.

```csharp
// Generate planar uv coordinates for the fourth uv set

using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        Mesh mesh = GetComponent<MeshFilter>().mesh;
        Vector3[] vertices = mesh.vertices;
        Vector2[] uvs = new Vector2[vertices.Length];

        for (int i = 0; i < uvs.Length; i++)
        {
            uvs[i] = new Vector2(vertices[i].x, vertices[i].z);
        }
        mesh.uv4 = uvs;
    }
}
```

Additional Resources: [Mesh.GetUVs](/engine/6000.7/script-reference/unityengine/mesh/getuvs.md), [Mesh.SetUVs](/engine/6000.7/script-reference/unityengine/mesh/setuvs.md), [Mesh.AcquireReadOnlyMeshData](/engine/6000.7/script-reference/unityengine/mesh/acquirereadonlymeshdata.md).
