I’ve been having this error and keep on failing to fix it, could anyone help me?
Here’s the code of the function the error is happening in:
void GenerateMesh()
{
Mesh newMesh = new Mesh();
List<Vector3> vertices = new List<Vector3>();
List<Vector3> normals = new List<Vector3>();
List<Vector2> uvs = new List<Vector2>();
List<int> indices = new List<int>();
int currentIndex = 0;
for (int x = 0; x < Size; x++)
{
for (int y = 0; y < Size; y++)
{
for (int z = 0; z < Size; z++)
{
Vector3Int offset = new Vector3Int(x, y, z);
if (BlockIDs[x, y, z] == 0) continue;
else
{
GenerateBlock_Top(ref currentIndex, offset, vertices, normals, uvs, indices, new Rect());
}
}
}
}
newMesh.SetVertices(vertices);
newMesh.SetNormals(normals);
newMesh.SetUVs(0, uvs);
newMesh.SetIndices(indices, MeshTopology.Triangles, 0);
newMesh.RecalculateTangents();
MeshFilter.mesh = newMesh;
MeshCollider.sharedMesh = newMesh;
// Set Texure (No texture Yet!)
RequiresMeshGeneration = false;
}
Thanks alot.