WaitForSeconds

hi, i used a code for my buttons to load my 99 levels, but i can’t added WaitForSeconds to wait before loading a level, when i did it on a function my code bug.

any suggestion. Thanks

public var sound1 : AudioClip;
public var sound2 : AudioClip;

private var i = 1;
private var s : int;

function Update ()
{
	for (i=1; i<99; i++)
	{
		if (Input.GetMouseButtonDown(0))
		{
			var hit : RaycastHit2D = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
			
			if(hit.collider.name == "button"+i)
			{
				audio.PlayOneShot(sound1);
				s = i;
			}
		}
		
		if (Input.GetMouseButtonUp(0))
		{
			if (s == i)
			{
				s = 0;
				audio.PlayOneShot(sound2);
				Application.LoadLevel ("Level "+i);
		    }
		}
	}
}

Sounds like you need to look over some Unity Scripting Basics.

Your problem sounds like a job for the Invoke method. Use it like this:

// Will call the method LoadLevel after 5 seconds
Invoke("LoadLevel", 5);