World generation

This is a script that is supposed to create the floor around the player if there is not a block there already but it freezes up unity

#pragma strict

var X : int;
var Y : int;
var Z : int;

var grassBlock : GameObject;
var hill : GameObject;

function Start()
{
	while(1)
	{
		for(var i=(X-64) ; i<(X+64) ; i++)
		{
			for(var j=(Z-64) ; j<(Z+64) ; j++)
			{
				if (!(Physics.Raycast (Vector3(i,0,j+2), Vector3.back, 2 )))
				{
					Instantiate (grassBlock, Vector3(i,0,j), Quaternion.identity);
				}
			}
		}
		yield;
	}
}

function Update () 
{
	X = transform.position.x;
	Z = transform.position.z;
}

You are doing 16k of Raycasts (128 * 128) each frame. That is a lot raycasts. But even worse, if all those raycast fail, you are creating 16K of game objects. That will freeze the app…at least for awhile. Not sure of the nature of your game, but you may want to look to an alternate solution for creating your terrain.