Since, that is the exact thing I am working on at the moment I will tell you the steps that I did.
First, I made the block class, with only the class and the two variables you need. isActive and block type. (which is an int)
I then made a definition class. This is the class that holds all the work horse stuff. It includes all of the block definitions and the mesh builder.
Next I built the chunk class, this is the one that just manages each chunk of data. It is based on a MonoBehaviour and it’s initialization process does the initial build of the block data. much like you have it. All of the building components and stuff like that are called from the data class though.
Lastly, I built a world script, this is placed on an object and it builds all of the chunks as you need them.
The differences:
I worked specifically on building the data class to be very simple, so where you have 1 piece of code that is 220 lines of code to build your render, I have may be 50 or so. I do this by sending references to functions rather than brute force building the mesh. I also created static UV and Vertex placement for each block. So consider that you have a Vector3[6,4] that contains 6 sides at 4 verts each. Then all you have to do is to match sides to that vector. (I could have, but didn’t create an enum block for the side names, but I figured that I would just keep them in order.)
OK, now all I had to do was run something like this:
for (int i=0; i<6; i++) {
if(bools[i]) AddFace(ref verts, ref faces, ref uvs, ref norms, i, position, blockType);
}
So AddFace then looks like this:
private static void AddFace(ref List<Vector3> verts,
ref List<int> faces,
ref List<Vector2> uvs,
ref List<Vector3> norms,
int direction,
Vector3 position,
int blockType
){
int index = verts.Count;
AddVerts(ref verts, direction, position);
AddFaces(ref faces, index);
AddUVs(ref uvs, direction, blockType);
AddNormals(ref norms, direction);
}
It makes the code very simple in the end and breaks it all down to easy to read functions rather than… switches or long lines of ifs.
I don’t know if that is what you are looking for, but is an observation.
Edit: Oh, if you haven’t checked it out, look at this: