I got an array where I store the name of the image (draw with GUI.DrawTexture). I do the blinking with this and works perfect:
if(Time.time % 2 < 1) { blink = true; }
else { blink = false; }
But, I need to show X seconds (lets say, 4) the first image from the array, another 4 seconds the second image, and so on. And when I reach the limit of the array, start again.
I have a function that’s called on OnGUI with this code, but it doesn’t work fine:
if(blink == true) {
if(lineCounter <= lineNumber.length) {
GUI.DrawTexture(Rect(Screen.width/2 - 406, Screen.height /2 - 180, 811, 360), Resources.Load("line" + lineNumber[lineCounter].ToString()), ScaleMode.StretchToFill, true, 0);
yield WaitForSeconds(4);
lineCounter++;
}
}
if(lineCounter > lineNumber) { lineCounter = 0; }
What I’m doing wrong?