change color after 2 seconds

Hello Everybody,

I have following code,

randomColor = Random.Range(0,5);
	//}
var chameleonColor : Color;


if(randomColor == 1.0)
{

GUI.color = Color.blue;
chameleonColor = GUI.color;
}
else 
if(randomColor == 2.0)
{

GUI.color = Color.red;
chameleonColor = GUI.color;

}
else
if(randomColor == 3.0)
{
GUI.color = Color.blue;
chameleonColor = GUI.color;
}
else
if(randomColor == 4.0)
{
	
GUI.color = Color.yellow;
chameleonColor = GUI.color;

}  
  //GUI.Label (Rect (290.0, 370, 200, 100), "blue");
  GUI.Button(chameleon, "chameleon"))

Its changing the color of chameleon based on the random number so that user cant guess which color is coming next. Its changing the color very fast in some miliseconds. What I want to do is that hold a color for 2 seconds and then bring new color. And yes the following code is inside OnGUI().

Thanks,

Any thoughts?

Is this information enough to get you started?

Here’s an idea. This is untested forum code.

var chameleonColor : Color; // Global Color

Start()
{

    ChangeColor();
}


function ColorChange()
{
   yield WaitForSeconds(2); // Wait for 2 seconds
   randomColor = Random.Range(0,5);  // Get new color

   // your if/then statements go here
   // assign the global chameleonColor here.
   // assign GUI Color.

   ColorDelay(); // Calls ColorDelay again.
}

Yes Tempest,

I came up with same solution.

Thanks anyways guys!