how to "blink" more often?

            if(Time.time % 2 > 1)
        {
            GUI.DrawTexture(helloRect, picture1);
        }
        else
        {
            GUI.DrawTexture(helloRect, picture2);
        }

How can I let this "blink" more often?

2 Answers

2

Something like:

if((Time.time * speed) % 2 > 1)

would be the quickest way to do it

thanks for the answer

Time.time is a float, not sure that % 2 of that would ever really be more than 1? Anyway there's a lot of ways to set up timers. I usually do something like this:

var rate = .5; // seconds
var lastCheck = 0.0;

Update()
{
  if ((Time.time - lastCheck) >= rate)
  {
    Do Something
    lastCheck = Time.time;
  }
}

which will 'Do Something' every 'rate' seconds. So you could toggle a boolean and pick a texture then. Smaller values of 'rate' will do it faster

My Do someting needs to be in the OnGUI, is that possible?

1.5 % 2 = 1.5, there's no issue with that

Regarding OnGUI - you'd have to check the time when Event.current.type == EventType.Repaint only

I use this all the time!