Question on either delay or unity limit for Instantiate (C#)

So I am working on a 3D/2D game, not sure how to really describe the ‘type’, in a sence sorta like a Grid game with a top down camera, but where you can rotate the camera in 3D space, and all objects are 3D but in a 2D grid/tile set layout.

What I am working on atm is a level loader, map creator.
All seems to work well unless I try to make a really large map, then it either hangs and acts like its going to crash, ie window says not responding but can sometimes finish, or not responding terms to windows closing the app. On small loads its quick and works fine so not sure if its due to a limit to how many things can be Instantiated at a time or if I just need to add a small delay or something to allow it to not take full control on a single function. Below is the code, you can run it just fine, but if i set the map size to like 1k x 1k, it seems to get more unstable, so was thinking a delay would work to allow it to not crash out but not sure how to add the waitforseconds part yet, or if there is just a limit to how many objects the engine itself can accualy handle to spawn in.
Any ideas?

using UnityEngine;
using System.Collections;

public class SpawnBlocks : MonoBehaviour
{
	public GameObject RockBlock;
	public GameObject DirtBlock;
	public GameObject EmptyBlock;
	public uint worldHeight = 100;
	public uint worldWidth = 100;

	void Start ()
	{
		CreateWorld();
	}

	void CreateWorld()
	{
		for(int x = 0; x < worldHeight; x++)
		{
			for(int z = 0; z < worldHeight; z++)
			{
				GameObject go = Instantiate(RockBlock);
				string temp = "BlockAt: " + x + " x " + z;
				go.name = temp;
				go.transform.position = new Vector3(this.transform.position.x + x*10, this.transform.position.y, this.transform.position.z + z*10); 

			}
		}
	}
}

I don’t think a delay will help you much. At 1000 x 1000 you’re talking about 1 million game objects with who knows how many verts, so yeah, it’s going to chug and likely crash. Most games that require massive maps have to get a little fancy with the way the load them in. They don’t have the whole map loaded at once, just the portion of the map immediately around the player. There’s a good Unite talk that covers some of the issues and one way to approach them here:

Thanks for the reply, when it does load its showing very low verts shown, and i guess thats what i was thinking of and basing it on :slight_smile: Some tinkering around i noticed just how much ram it was goboling up guess should have looked more first.
But i think a limit on 100x100 or 250x250 seems large enough anyways for almost all the maps, its intended to be sorta like a DungeonKeeper/EvilGenius style layout to tinker with ideas and code but thanks for the idea on ways to work around it for some other ideas i was going to try to throw in down the line