Quantcast
Channel: Answers by "pixel_fiend"
Viewing all articles
Browse latest Browse all 18

Answer by pixel_fiend

$
0
0
This solution obfuscates the Coroutine, and uses Actions, which are generic callback functions. Make a base class for your scripts that extends MonoBehavior. This will allow use of Coroutine. using UnityEngine; using System.Collections; using System; public class ExtendedBehavior : MonoBehaviour { public void Wait(float seconds, Action action){ StartCoroutine(_wait(seconds, action)); } IEnumerator _wait(float time, Action callback){ yield return new WaitForSeconds(time); callback(); } } Then, in ExtendedBehavior classes, you can use Wait. Wait (5, () => { Debug.Log("5 seconds is lost forever"); });

Viewing all articles
Browse latest Browse all 18

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>