Version: 2023.2
언어: 한국어
public Vector2[] uv3 ;

설명

The texture coordinates (UVs) in the third channel.

This channel is also commonly called "UV2". It maps to the shader semantic `TEXCOORD2`. When you call Mesh.HasVertexAttribute, this channel corresponds to VertexAttribute.TexCoord2.

Unity can use this channel to store input UVs that it uses to calculate the final UVs for real-time lightmaps. For more information, see Lightmap UVs.

**Note:** When Unity renders a MeshRenderer that references this mesh and uses Realtime Global Illumination, Unity streams the data in MeshRenderer.enlightenVertexStream to `TEXCOORD2` instead of the data in this channel. For more information, see Lightmap UVs.

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.

// Generate planar uv coordinates for the third 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.uv3 = uvs; } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961