/// <summary>Invoke the given action each frame while predicate resolves to true.</summary> /// <param name="mb">The MonoBehaviour to run this from.</param> /// <param name="actionToCall">The action to invoke.</param> /// <param name="predicate">The predicate to check.</param> /// <param name="skipFrames">The amount of frames to skip between actions.</param> public static Coroutine ActionEachFrameWhilePredicate(this MonoBehaviour mb, Action actionToCall, Func <bool> predicate, int skipFrames = 0) { return(mb.ActiveInHierarchy() ? mb.StartCoroutine(mb.ActionEachFrameWhilePredicateCoroutine(actionToCall, predicate, skipFrames)) : null); }
/// <summary>Invoke the given action after the given amount of render frames</summary> /// <param name="mb">The MonoBehaviour to run this from.</param> /// <param name="actionToStart">The given action to invoke</param> /// <param name="framesToWait">The amount to wait before action, in frames</param> public static Coroutine ActionInFrames(this MonoBehaviour mb, Action actionToStart, int framesToWait) { return(mb.ActiveInHierarchy() ? mb.StartCoroutine(mb.ActionInFramesCoroutine(actionToStart, framesToWait)) : null); }
/// <summary>Calls the given action every frame for the given amount of seconds. /// The parameter will be the amount of seconds already passed since the start frame.</summary> /// <param name="mb">The MonoBehaviour to run this from.</param> /// <param name="actionToCall">The action to call every frame with the seconds count.</param> /// <param name="amountOfSecondsToTake">The time frame in which to call the action every frame.</param> public static Coroutine ActionEachFrameForSeconds(this MonoBehaviour mb, Action <float> actionToCall, float amountOfSecondsToTake) { return(mb.ActiveInHierarchy() ? mb.StartCoroutine(mb.ActionEachFrameForSecondsCoroutine(actionToCall, amountOfSecondsToTake)) : null); }
/// <summary>Invoke the given action in the given amount of seconds</summary> /// <param name="mb">The MonoBehaviour to run this from.</param> /// <param name="actionToStart">The given action to invoke</param> /// <param name="secondsToWait">The amount to wait before action, in seconds</param> public static Coroutine ActionInSeconds(this MonoBehaviour mb, Action actionToStart, float secondsToWait) { return(mb.ActiveInHierarchy() ? mb.StartCoroutine(mb.ActionInSecondsCoroutine(actionToStart, secondsToWait)) : null); }
/// <summary>Checks predicate every frame until predicate resolves to true and then calls action.</summary> /// <param name="mb">The Monobehaviour to run this from.</param> /// <param name="actionToCall">The action to call when predicate fulfilled.</param> /// <param name="predicate">The predicate to check for every frame.</param> public static Coroutine ActionWhenPredicate(this MonoBehaviour mb, Action actionToCall, Func <bool> predicate) { return(mb.ActiveInHierarchy() ? mb.StartCoroutine(mb.ActionWhenPredicateCoroutine(actionToCall, predicate)) : null); }