Skip to content

Instantly share code, notes, and snippets.

@willis81808
Last active July 31, 2020 23:37
Show Gist options
  • Select an option

  • Save willis81808/7ef685984785d39f91444efdbb63fc02 to your computer and use it in GitHub Desktop.

Select an option

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
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