/// <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); }