Delay gui script

Hello, I am trying to make a gui delay a few seconds before becoming visible when the game starts.
Like if we start the game after 4 seconds the gui becomes visible .
How can this be approached with a JavaScript?
Thank you :slight_smile:

What do you use ? OnGUI ? GUITextures/GUIText ?

Anyway, I would suggest a coroutine like that :

var alpha:float = 0;
var targetAlpha:float = 0;
var fadeInSpeed:float = 10;
var delay:float = 4;

function Start()
{
    DelayedGUI();
}

function Update()
{
	alpha = Mathf.Lerp(alpha, targetAlpha, Time.deltaTime*fadeInSpeed);
}

function DelayedGUI()
{
	yield WaitForSeconds(delay);
	targetAlpha = 1;
}

Then all you have to do is to set the alpha of your GUI to alpha like this (Iā€™m assuming you use Unity GUI :

Color c = GUI.color;
c.a = alpha;
GUI.color = c;