I want to fade in my scene and I want to delay it for 3 seconds but function WaitForSeconds don’t work
I read in document and write in correct structure but it still don’t work
what did i do wrong?
#pragma strict
var fadeTexture : Texture2D;
var fadeSpeed = 0.15;
var drawDepth = -1000;
private var alpha = 0.0;
private var fadeDir = -1;
function OnGUI(){
FadeIn();
}
function FadeIn()
{ yield WaitForSeconds (2);
alpha -= fadeDir * fadeSpeed * Time.deltaTime;
alpha = Mathf.Clamp01(alpha);
GUI.color.a = alpha;
GUI.depth = drawDepth;
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeTexture);
if(GUI.color.a == 0)
{
Application.LoadLevel("Scene1");
}
}