网格的法线。
如果网格不包含法线,则返回一个空数组。
// Rotate the normals by speed every frame
using UnityEngine;
public class ExampleClass : MonoBehaviour { float speed = 100.0f;
// Update is called once per frame void Update() { // obtain the normals from the Mesh Mesh mesh = GetComponent<MeshFilter>().mesh; Vector3[] normals = mesh.normals;
// edit the normals in an external array Quaternion rotation = Quaternion.AngleAxis(Time.deltaTime * speed, Vector3.up); for (int i = 0; i < normals.Length; i++) normals[i] = rotation * normals[i];
// assign the array of normals to the mesh mesh.normals = normals; } }
注意:
normals 分配给顶点,而不是三角形。