SetTriangles does not accept a NativeArray. Best way around this?

Using unity 2020.3, Burst Compiler and Jobs I’m trying to create a fast mesh generator. Everything works with the following code:

    JobHandle createMeshJobHandle = createMeshJob.Schedule();
    createMeshJobHandle.Complete();

    // Assign 
    mesh.SetVertices( createMeshJob.vertices );
    mesh.triangles = createMeshJob.triangles.ToArray();
    mesh.SetColors( createMeshJob.colors );

I don’t like that I am converting the createMeshJob.triangles to an array instead o fusing the mesh.triangles setter. How can I use SetTriangles instead without doing the .ToArray()?

You are either looking for

mesh.SetIndexBufferData

implementation example from Keijiro
https://www.github.com/keijiro/NoiseBall5/tree/master/Assets%2FNoiseBallRenderer.cs

OR

MeshDataArray (similar API)

Main advantage over mesh.SetIndexBufferData is that it can be IJob-ified
So it won’t block the main thread when implemented properly (big win in performance departament).