for loop crash...

Vector3 gridStart = transform.position - new Vector3(worldX, worldY, worldZ);
for(float x =0F; x<worldX; x += snap) {
Debug.Log (x);
for(float y =0F; y<worldY; y += snap) {
for(float z =0F; z<worldZ; z += snap) {
GameObject gridCube = Instantiate(prefab) as GameObject;
Vector3 startPosition = transform.position + new Vector3(worldX, worldY, worldZ);
gridCube.transform.position = new Vector3(gridStart.x + x, gridStart.y, gridStart.z + z);
gridCubesList.Add(gridCube);
gridCubes = gridCubesList.ToArray();
}
}
}

So this code totally freezes my editor. What’s the problem?

what are the values of worldX/Y/Z? if they’re not small, it’s likely that it’s just taking a very long time…

… especially if you’re converting the list to an array EVERY iteration…

you don’t need to do that at all - you can index the list like an array.