Last active
July 31, 2020 23:37
-
-
Save willis81808/7ef685984785d39f91444efdbb63fc02 to your computer and use it in GitHub Desktop.
OBSOLETE! Everything done here can be accomplished using the ExtensionMethods.cs definitions for MonoBehaviour
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections; | |
| using UnityEngine; | |
| public class TimerManager : MonoBehaviour | |
| { | |
| private static TimerManager _instance; | |
| private static TimerManager Instance | |
| { | |
| get | |
| { | |
| if (_instance == null) | |
| { | |
| _instance = new GameObject("Timer Manager").AddComponent<TimerManager>(); | |
| DontDestroyOnLoad(_instance.gameObject); | |
| } | |
| return _instance; | |
| } | |
| } | |
| public static void ExecuteAfter(float seconds, Action action) | |
| { | |
| Instance.StartCoroutine(ExecuteAfterCoroutine(seconds, action); | |
| } | |
| private static IEnumerator ExecuteAfterCoroutine(float seconds, Action action) | |
| { | |
| yield return new WaitForSeconds(seconds); | |
| action(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment