How to merge per triangle UVs

I am trying to generate correct UVs for meshes I have combined with CombineMeshes().

UnityEditor.Unwrapping.GeneratePerTriangleUV() seems to do what I want, but the documentation just says “You’ll need to merge them yourself.”
This function seems to be giving me back one UV pair per triangle, but I don’t know how to merge/map those onto the vertex UV pairs that the mesh seems to have (the UV array is the same size as the vertex array, while the generated UV array is the same size as the triangle array).

Here is my function:

public GameObject MeshCombination(Material material, CombineInstance[] combines)
		GameObject newMeshObj = new GameObject(;
		MeshFilter targetFilter = null;
		targetFilter = newMeshObj.AddComponent<MeshFilter>();
		targetFilter.sharedMesh = new Mesh();
		Vector2[] triangleUV = UnityEditor.Unwrapping.GeneratePerTriangleUV(targetFilter.sharedMesh);
		// How do I merge the per triangle UVs and assign them to the mesh?

		targetFilter.renderer.material = material;		
		return newMeshObj;

Thanks in advance for whatever help you guys can give me!

I have a code which works for me. However I cannot use that in my project as UnityEditor code cannot be used in the Builds.
Below is the code:

 private static Vector2[] GenerateUvs(Mesh mesh)

            Vector2[] uvs = new Vector2[mesh.vertices.Length];
            Vector2[] all = UnityEditor.Unwrapping.GeneratePerTriangleUV(mesh);
            int[] triangles = mesh.triangles;

            int count = 0;
            while (count < uvs.Length)
                for (int i = 0; i < triangles.Length; i++)
                    if (triangles *== count)*

uvs[count] = all*;*

return uvs;

// return null;