Version: 2020.1
public Vector2[] uv ;

描述

网格的基础纹理坐标。

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

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