- Home /
The question is answered, right answer was accepted
Draw line on polygons in editor
Hi, i would like to draw line in editor between vectors but not "all to all", just between neigbours (polygons of mesh). That's what i have ATM (drawing sphere on vectors:
void OnDrawGizmos()
{
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
Gizmos.color = color; // color is public variable
for (int i = 0; i < vertices.Length; i++) {
Gizmos.DrawSphere(transform.TransformPoint(vertices[i]), size);
}
}
Answer by Frozaken · Nov 07, 2016 at 08:25 PM
defining neighbours can be a little hard at times, although you could try something like
void OnDrawGizmos()
{
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
Gizmos.color = color; // color is public variable
for (int i = 0; i < vertices.Length; i++)
{
Gizmos.DrawSphere(transform.TransformPoint(vertices[i]), size);
if (transform.TransformPoint(vertices[i + 1]) != null)
{
Gizmos.DrawLine(transform.TransformPoint(vertices[i]), transform.TransformPoint(vertices[i + 1]));
}
}
}
i cant quarantee this will work and it might not give you the solution you worked, you could do a range check aswell, but this script should make a long snake going from vert to vert
Some are ok but not all polygons are showed and i have lines between vertexs which comes through mesh.
It's better than nothing, enough for this purpose, thanks @$$anonymous$$aken.
Follow this Question
Related Questions
Adding drag function to a polygon editor 1 Answer
free unity 5 voxel engine 1 Answer
Persistent selection 1 Answer
How to create persistent handles in Editor Scene View? 1 Answer
Turn scene view "full screen" off 0 Answers