Performance While Loading Map

Hey everyone!

I’m trying to figure out why my map takes such an amazingly long time to load. I have Unity Basic, so I can’t access any of the diagnostic tools I’ve heard about. But I just added a simple timer to the load, and it takes about 23 seconds to load. My computer isn’t a wimp; what am I doing wrong, and how could I optimize this?

function InitialGridLoadup (){
	tilePrefab = Resources.LoadAssetAtPath("Assets/Prefabs/Tile/Tile.prefab", Object);
	wallPrefab = Resources.LoadAssetAtPath("Assets/Prefabs/Tile/Wall.prefab", Object);
	ceilingPrefab = Resources.LoadAssetAtPath("Assets/Prefabs/Tile/Ceiling.prefab", Object);
	
	var timeStamp = Time.time;
	Debug.Log(timeStamp);
	
	for ( var x : int = 0; x < mapX; x++ ) {
		for ( var z : int = 0; z < mapZ; z++ ) {
			// Creates the tile
			TileArray[x, z] = new Tile(1, false, 10, x, z);
			Debug.Log(x + ", " + z);
			
		}
		Debug.Log(Time.time - timeStamp);
		yield;
	}
	
	Debug.Log(Time.time - timeStamp);
}

class Tile{ 
	var type : int;
	var visible : boolean = false;
	var health : int;
	var x : float;
	var z : float;

	
	function Tile(newType, isVisible, newHealth, newX, newZ){//constructor
		this.type = newType;
		this.visible = isVisible;
		this.health = newHealth;
		this.x = newX;
		this.z = newZ;
	}
	
	function Name() : String {return ("Tile" + x + "x" + z);}
}

Normally, I’d also be adding the following code under the “Creates the tile” comment, which makes it go even slower.

	var tile : Transform = Instantiate(tilePrefab.transform, new Vector3(x,0,z),Quaternion.identity);

To give you an idea of what I’m doing: I’m building a tile-based map from scratch, and I’m trying to build it with good performance in mind.

Mostly it’s the Debug.Logs that’s slowing it down. Take all Debug.Logs out of loops if you want anything like reasonable performance.

how large is mapZ and mapX?
depending on that, your code is not even remotely computer and loading friendly, if you exceed what you need to fill the screen there (<= 64) and even at 64 its already a rather large bomb as thats 4096 objects to instantiate for example.