public Vector3[] 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; } }

注意:若要对 normals 进行更改,从 Mesh 复制 法线十分重要。复制和更改 normals 之后,normals 即可重新分配回 Mesh

__注意:__.normals 会分配给顶点,而不是三角形。

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961