protected virtual void Update() { switch (state) { case AudioTimerState.AT_WAIT: if (Playing) { timer = 0; state = AudioTimerState.AT_PLAY; TimedAction(); } break; case AudioTimerState.AT_PLAY: if (Playing) { timer += Time.deltaTime; if (timer >= timeInterval) { timer = 0; TimedAction(); } } else { timer = 0; state = AudioTimerState.AT_WAIT; } break; default: Debug.LogWarning("Unhandled AudioTimerState \"" + state.ToString() + "\" in switch statement"); break; } }
protected virtual void Start() { state = AudioTimerState.AT_WAIT; timer = 0; }