Skip to content

Instantly share code, notes, and snippets.

Created September 11, 2016 14:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Show mesh vertices and normals in sceneview [Unity3D]
// author: Stijn Raaijmakers (@bugshake)
// date: 11 sep 2016
using UnityEngine;
using UnityEditor;
/// <summary>Add this component to any GameObject with a MeshFilter, then select it in the editor</summary>
public class MeshInspector : MonoBehaviour
void OnDrawGizmosSelected()
Mesh mesh = GetComponent<MeshFilter>().sharedMesh;
if (mesh != null)
var verts = mesh.vertices;
var norms = mesh.normals;
for (int i = 0; i < verts.Length && i < norms.Length; ++i)
Vector3 p1 = transform.TransformPoint(verts[i]);
Vector3 p2 = transform.TransformPoint(verts[i] + norms[i]);
Gizmos.color =;
Gizmos.DrawSphere(p1, .1f);
Gizmos.color = Color.yellow;
Gizmos.DrawLine(p1, p2);
Handles.Label(p1, i.ToString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment