- Home /

# Importing edges and vertices only

I'm trying to bring a mesh with only edges and vertices from Blender. I'm thinking of taking the coordinates and creating a edge collider 2D from it later.

I use simple code to draw lines where the edge collider would go.

```
Mesh mesh = GetComponent<MeshFilter>().sharedMesh;
for(int i = 0; i < mesh.vertexCount-1; i++)
{
Gizmos.DrawLine(mesh.vertices[i], mesh.vertices[i+1]);
}
```

How to get the edges in correct order and figure out which vertex is connected to which?

**Answer** by Cherno
·
Jan 18, 2015 at 03:38 PM

Take a look at the mesh class: It has an array of vertices which are just Vertex3s, so basically the positions of the vertices are stores therein. Then you have an array of triangles which are actually references (indices) to the vertices a triangle consists of, stored as three ints.

You can just copy that functionality for your own needs: The vertices are the same of course because you need the coordinates of them. Triangles don't exist here but the edges do (even if theyx are just represented by a Gizmo line or whatever). The edges can be stored the same way triangles do, but with two int references instead of three. So you structure might look like this:

```
Vector3[] vertices = new Vector3[] {
new Vector3(0,0,0),//position of the first vertex
new Vector3(1,3,2)//position of the second vertex
new Vector3(5,6,2)//...
new Vector3(3,2,0)
};
int[] edges = new int[] {
0,1,//vertex indices for the first edge
1,2,//vertex indices for the second edge
2,3//vertex indices for the third edge
}
```

It doesn't matter in what order the edges are stores as long as every two indices that go together to form one edge from two vertices are kept together.

Edit: I may have misunderstood your question after reading it again. Edges can't be exported to my knowledge, and since there are no triangles to build a mesh from, you won't have any references of which vertices are connected to form triangles or edges. How would the program know it, anyway? the only way I can think of is to just determine it by going from left to right and using that as a way to put the vertex indices in order to determine edges.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.