Most efficient method to create mesh from array

Hey guys. I was wondering, that what is the most efficient method to generate mesh from array? Because instantiating is damn slow. So I thought that I could just store the cubes data in 3D array like 0 - air, 1 - block, but how can I easily make a mesh from that? And yes I checked the minecraft and after playing minecraft, but I couldn’t understand what’s going on, because it was really complex, and I would need to get only the roots first to understand.

The code is bit messy but will give the idea.

//creating cube from many cubes, than if it's in radius/distance*2 it's 0-air,
//if it's in radius it's 1-dirt
//if it's in radius-5 it's 2-stone
//I store it into a 3d array named planet
//here should I rebuild the mesh from the array I have.
//than if raycast and mouse -- set the block id to 0--air/destroy it 

I haven’t posted the whole code, because it’s just while(x <= …) etc.


You wouldn’t instantiate cubes, you’d use the Mesh class to create meshes.