How can i merge mesh vertices using a script?

Long story short: i want to merge two meshes using a C# script. Though what i want is not just two meshes made into one. I want the vertices of the mesh to bind to each other if close enough. Like this:

The meshes on this picture are a bit wonky. Its something in threw together quite quickly in blender.

Can this even be done programatically in unity? I need this merging done programatically and then preferably in C#. Any help is greatly appreciated. Thanks in advance.

To be honest, it probably IS possible, however you might want to take a look Mesh.vertices.

Take a look at this and the sample script. Notice how they manipulate the vertices.

I found this tool set, the Oasis Mesh Editor, it can Split Vertices and Merge Vertices back together, along with a bunch of other modeling tools. Oasis Mesh Editor | Modeling | Unity Asset Store

Perhaps this tool set will work to just extend one mesh to envelope the other. =)