private void Update() { if (paused) { return; } while (added.Count > 0) { timers.Add(added.Dequeue()); } while (removed.Count > 0) { timers.Remove(removed.Dequeue()); } for (int i = timers.Count - 1; i >= 0; i--) { TimeInfoIndexed currentTimer = timers[i]; if (currentTimer.useSequence == false) { TimeNode currentNode = currentTimer.info.nodes[currentTimer.currentIndex]; //Whatever the current index is, reduce its time by deltaTime currentNode.time -= Time.deltaTime; //If the timer has run out if (currentNode.time <= 0) { //Run the callback currentNode.callback(); //Increase the index, if it's over the amount of nodes we have, delete it. if (currentTimer.repeat) { currentNode.time = currentTimer.delaySavedTime; } currentTimer.currentIndex++; if (currentTimer.currentIndex >= currentTimer.info.nodes.Length) { if (currentTimer.repeat) { currentTimer.currentIndex = 0; } else { timers.RemoveAt(i); } } } } else { //Decrease the time currentTimer.optionalSequenceTime -= Time.deltaTime; if (currentTimer.optionalSequenceTime <= 0) { //If its time to move to the next step, do so and set the new time if (currentTimer.optionalSequence.MoveNext()) { currentTimer.optionalSequenceTime = currentTimer.optionalSequence.Current; } else { timers.RemoveAt(i); } } } } }