可查看法线的脚本normals line script in unity
using System;using UnityEngine;
public class ShowNormals : MonoBehaviour {
public float length = 1;
public Vector3 bias;
public Boolean isShowDebugPoint;
// Update is called once per frame
private void OnValidate()
{
}
private void OnDrawGizmos()
{
if (isShowDebugPoint)
{
// 获取网格法线
Mesh mesh = GetComponent<MeshFilter>().sharedMesh;
Vector3[] vertices = mesh.vertices;
Vector3[] normals = mesh.normals;
for (var i = 0; i < normals.Length; i++)
{
Vector3 pos = vertices;
pos.x *= transform.localScale.x;
pos.y *= transform.localScale.y;
pos.z *= transform.localScale.z;
pos += transform.position + bias;
Gizmos.DrawLine
(
pos,
pos + normals * length);
}
}
}
}
楼主是超人 好帖就是要顶 真心顶 很好哦 不错不错
页:
[1]