Version: 2020.1
public Vector2[] uv4 ;

描述

网格的第四个纹理坐标集(如果存在)。

// 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; } }

注意:必须在网格外部创建或修改纹理坐标。 以上脚本示例将创建 UV 数组,将纹理坐标分配给 UV 数组,然后将数组分配给 Mesh