Manual Scripting API Search scripting... unity.
com
Version: Unity 6.1 (6000.1) C#
Mesh.uv
Leave feedback
SWITCH TO MANUAL
public Vector2[] uv;
Description
The texture coordinates (UVs) in the first channel.
This channel is also commonly called "UV0". It maps to the shader semantic `TEXCOORD0`. When you call Mesh.HasVertexAttribute, this channel corresponds to
VertexAttribute.TexCoord0.
By default, Unity uses this channel to store UVs for commonly used textures: diffuse maps, specular maps, and so on.
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 GetUVs and SetUVs 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.
using UnityEngine;
using System.Collections;
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.uv = uvs;
}
}
Additional resources: GetUVs, SetUVs, AcquireReadOnlyMeshData.
Did you find this page useful? Please give it a rating:
Report a problem on this page
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com .
Copyright ©2005-2025 Unity Technologies. All rights reserved. Built from: 6000.1.15f1 (090817289254). Built on: 2025-07-28.
Tutorials Community Answers Knowledge Base Forums Asset Store Terms of use Legal Privacy Policy Cookies Do Not Sell or Share My Personal
Information Your Privacy Choices (Cookie Settings)