Legacy Documentation: Version 5.6 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Mesh.normals

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public var normals: Vector3[];
public Vector3[] normals;

Description

The normals of the Mesh.

If the Mesh contains no normals, an empty array is returned.

#pragma strict
// Rotate the normals by speed every frame
var speed: float = 100.0f;
// Update is called once per frame
function Update() {
	// obtain the normals from the Mesh
	var mesh: Mesh = GetComponent.<MeshFilter>().mesh;
	var normals: Vector3[] = mesh.normals;
	// edit the normals in an external array
	var rotation: Quaternion = Quaternion.AngleAxis(Time.deltaTime * speed, Vector3.up);
	for (var i: int = 0; i < normals.Length; i++)
		normals[i] = rotation * normals[i];
	// assign the array of normals to the mesh
	mesh.normals = normals;
}
// 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; } }

Note: To make changes to the normals it is important to copy the normals from the Mesh. Once the normals have been copied and changed the normals can be reassigned back to the Mesh.