c# trying to cause events at certain time

I am using UniStorm and its time system. I want certain events to happen at certain intervals, but don’t want the Update() tread full of if statements if possible.

Is there maybe a better way to check for:

if(time == 1) {}
if(time == 2){}
void Start()
{
    StartCoroutine(Event1());
}

IEnumerator Event1()
{
    while(true)
    {
        // do smth every 5sec
        yield return new WaitForSeconds(5.0f);
    }
    
    yield return 0;
}

thanks, but not system real time. UniStorm has a built in day, minute, hour, year of its own. I am using that time system.

The point is that you should use IEnumerators, you can check UniStorm timers in there as well.

oo ok. I guess I have some research to do then. I don’t know those

You could use a coroutine, but if you’re getting the time from UniStorm instead of real time, then Update actually sounds like the appropriate place. For an interval, just keeping track of the most recent time it happened should work:

private int interval = 5;
private int lastTime;  

void Start ()
{
  lastTime = GetTime();
}

void Update ()
{
  int time = GetTime();
  if(time >= lastTime + interval) 
  {
    lastTime += interval;
    // Do your action
  }
}

Where GetTime is however you get the time from UniStorm. Change int to float if appropriate, obviously.