Version: 2017.2
public Vector2[] uv4 ;

描述

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

// Generate planar uv coordinates for all 4 uv sets

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.uv2 = uvs; mesh.uv3 = uvs; mesh.uv4 = uvs; } }

注意:纹理坐标必须在网格进行修改或 创建。在上面的脚本示例中,UV 创建为新数组,然后将 纹理坐标分配给该数组。分配这些坐标后, 该数组即可分配给 Mesh