Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.Events;
- public class TimerComponent : MonoBehaviour
- {
- public float Timeout;
- public bool Repeat;
- public UnityEvent TimerElapsed;
- private float Timer { get; set; }
- // Use this for initialization
- public void Start()
- {
- Timer = 0;
- }
- // Update is called once per frame
- public void Update()
- {
- Timer += Time.deltaTime;
- if (Timer >= Timeout)
- {
- TimerElapsed.Invoke();
- if (Repeat)
- {
- Timer = 0;
- }
- else
- {
- this.enabled = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement