Hi guys. I’ve tried searching the forums and countless coding websites, however, I can’t seem to find the solution. I’m trying to get the script to wait before it fades out suddenly, I don’t want it fading out slowly over the scene. Here’s my code:
var theTexture : Texture2D;
function DoEvent(){
yield WaitForSeconds(10);
OnGUI();
}
function OnGUI()
{
GUI.color.a = Mathf.Lerp(0.0, 1.0, (Time.time / 2));
GUI.DrawTexture(Rect(0,0,Screen.width, Screen.height), theTexture);
}
Well, it makes no sense that you call the function OnGUI with in the DoEvent function. OnGUI is already called every 33 milliseconds, or something like that. Change the function. As you have it, your yield serves no purpose.
I ALWAYS jump the gun. But if I can get a solution, that’s fine. I figured my experience in other languages would help me here, but Unity seems to have taken Javascript and jumbled it all up…
It’s not Javascript, it’s Unityscript. They call it Javascript 'cause it has some similarities and “Javascript” is more attractive to new users than “Unityscript” (there are threads discussing this waaaay beyond what I can say on it).
Think of it more as a far more lenient alternative to C#.