/// <summary> /// Sets the update routine for the object and update phase. /// </summary> static public Routine SetUpdateRoutineGenerator(this MonoBehaviour inHost, Func <IEnumerator> inUpdateFunc, RoutinePhase inPhase = RoutinePhase.Update) { string phaseName = GetPhaseUpdaterName(inPhase); Routine routine = Routine.Find(inHost, phaseName).Replace(Routine.StartLoopRoutine(inHost, inUpdateFunc)).SetPhase(inPhase); Fiber fiber = Manager.Get().Fibers[routine]; if (fiber != null) { fiber.SetNameUnchecked(phaseName); } return(routine); }
/// <summary> /// Sets the update routine for the object and update phase. /// </summary> static public Routine SetUpdateRoutine(this MonoBehaviour inHost, IEnumerator inUpdateLoop, RoutinePhase inPhase = RoutinePhase.Update) { Manager m = Manager.Get(); if (m != null) { string phaseName = GetPhaseUpdaterName(inPhase); Routine routine = Routine.Find(inHost, phaseName) .Replace(inHost, inUpdateLoop).SetPhase(inPhase); Fiber fiber = m.Fibers[routine]; if (fiber != null) { fiber.SetNameUnchecked(phaseName); } return(routine); } return(Routine.Null); }
/// <summary> /// Returns the update routine associated with the object and update phase. /// </summary> static public Routine GetUpdateRoutine(this MonoBehaviour inHost, RoutinePhase inPhase = RoutinePhase.Update) { return(Routine.Find(inHost, GetPhaseUpdaterName(inPhase))); }