Tanoda
DelayAction.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using UnityEngine;
6
7public class DelayAction : MonoBehaviour
8{
9 public bool autostart = false;
10 public float delay = 1.0f;
11 public UnityEvent action;
12
13 private void Start()
14 {
15 if (autostart)
16 {
17 Trigger();
18 }
19 }
20
21 public void Trigger()
22 {
23 StartCoroutine(Delay());
24 }
25
26 private IEnumerator Delay()
27 {
28 yield return new WaitForSeconds(delay);
29 action.Invoke();
30 }
31}
void Trigger()
Definition: DelayAction.cs:21
UnityEvent action
Definition: DelayAction.cs:11
bool autostart
Definition: DelayAction.cs:9
float delay
Definition: DelayAction.cs:10