Map Generation with perlin noise lags after 256 x 256 cube array

I have a Unity project in which I have the necessary code to create a texture anywhere from 2x2 to 512x512 and fill it with perlin noise. I am using this texture to populate a map of blocks (think minecraft) .

The map generates correctly, but Unity starts lagging with that many cubes?

Sample Image

This is an image of the generated map, 256x256.

Any leads in the right direction would be appreciated, I’m just stumped on how to get passed this.

This is the method to populate the map

private void GenerateMap ()
{
	for (int x = 0; x < creator.resolution; x++) {
		for (int z = 0; z < creator.resolution; z++) {
			Object newCube = Instantiate (cube, new Vector3(x, Mathf.Round (texture.GetPixel (x, z).b * 10), z), Quaternion.identity);
			newCube.name = "Cube: " + x + ", " + z;
		}
	}
	Debug.Log ("Finished generating world");
}

So you have about 65000 GameObjects in hierarchy? That’s the problem. Not to mention that all the cube meshes also have vertices to render their bottom faces and side faces that are blocked by neighboring cubes. It will get even worse if you add colliders to interact with them etc.

Have you studied how Minecraft does things? In optimal case that whole 256x256 terrain could be a single mesh in 1 gameobject. That way it would require minimal CPU work and the GPU would handle almost everything. But for practical readons it ahold be cut into a few chuncks.

Here’s a pretty comprehensive tutorial of everythin involved