Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

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

Sumbission failed

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

Close

Cancel

public var normals: Vector3[];
public Vector3[] normals;
public normals as Vector3[]

Description

The normals of the mesh.

If the mesh contains no normals an empty array will be returned.

	// Rotate the normals by speed every frame

var speed = 100.0;

function Update () { var mesh : Mesh = GetComponent(MeshFilter).mesh; var normals : Vector3[] = mesh.normals;

var rotation : Quaternion = Quaternion.AngleAxis(Time.deltaTime * speed, Vector3.up); for (var i = 0; i < normals.Length; i++) normals[i] = rotation * normals[i];

mesh.normals = normals; }
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public float speed = 100.0F;
    void Update() {
        Mesh mesh = GetComponent<MeshFilter>().mesh;
        Vector3[] normals = mesh.normals;
        Quaternion rotation = Quaternion.AngleAxis(Time.deltaTime * speed, Vector3.up);
        int i = 0;
        while (i < normals.Length) {
            normals[i] = rotation * normals[i];
            i++;
        }
        mesh.normals = normals;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public speed as float = 100.0F

	def Update() as void:
		mesh as Mesh = GetComponent[of MeshFilter]().mesh
		normals as (Vector3) = mesh.normals
		rotation as Quaternion = Quaternion.AngleAxis((Time.deltaTime * speed), Vector3.up)
		i as int = 0
		while i < normals.Length:
			normals[i] = (rotation * normals[i])
			i++
		mesh.normals = normals