normals
The normals of the Mesh.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public Vector3[] normals { get; set; }
Remarks
If the Mesh contains no normals, an empty array is returned.
// Rotate the normals by speed every frameusing 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; }}
Note: To make changes to the Mesh.normals it is important to copy the normals from the Mesh. Once the Mesh.normals have been copied and changed the Mesh.normals can be reassigned back to the Mesh.
Note: Mesh.normals are assigned to vertices, not triangles.