Skip to content

Instantly share code, notes, and snippets.

@farukcan
Created January 16, 2022 20:09
Show Gist options
  • Save farukcan/ddf7dfb10759de66db5a73801073b28f to your computer and use it in GitHub Desktop.
Save farukcan/ddf7dfb10759de66db5a73801073b28f to your computer and use it in GitHub Desktop.
Delay UnityEvent : Delayed Execution Of UnityEvents
// 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