Combine mesh and merge the neighboring vertices

is there a quick way to make this operation ?

for example when you want to change the different elements and collect the mesh again very often.

Mesh.Combine or other tools - can do it, but they do not allow to merge vertices that are located near...

maybe i need to use SortedDictonary and IComparer(Vertex) - but then takes a long time to build triangles.

please help.

This is very tricky to do properly.

First you would have to find vertexes that are on top of each other. This is at least O(n log n) complexity, increasing in cost as the number of vertexes rises. Then for each match you would delete one vertex, then find all the triangles that reference the second vertex and change that reference to the first vertex.

Of course, none of this would preserve the texture or colour values for the vertex, so the mesh couldn't reliably have textures or colours in it.