Created
January 16, 2022 20:09
-
-
Save farukcan/ddf7dfb10759de66db5a73801073b28f to your computer and use it in GitHub Desktop.
Delay UnityEvent : Delayed Execution Of UnityEvents
This file contains 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
// Author: github.com/farukcan | |
// Requires: RunB83 - https://github.com/farukcan/unity-utilities | |
// delay.Invoke(1f); | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Events; | |
public class Delay : MonoBehaviour | |
{ | |
public UnityEvent events; | |
private Run run; | |
public void Invoke(float time) | |
{ | |
run = Run.After(time, events.Invoke); | |
} | |
private void OnDisable() { | |
if(run != null){ | |
run.Abort(); | |
run = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment