bool IEnumerator.MoveNext() { if (m_Enumerators != null) { for (int i = 0; i < m_Enumerators.Count; ++i) { if (m_Enumerators[i] != null) { Fiber fiber = m_Manager.ChainFiber(m_Enumerators[i]); fiber.SetNestedOwner(this); fiber.SetParentFiber(m_ParentFiber); m_Fibers.Add(fiber); } } m_Enumerators.Clear(); m_Enumerators = null; if (m_Fibers.Count == 0) { return(false); } } if (m_Fibers != null) { if (m_Fibers.Count > 0) { bool prevIterating = m_Iterating; m_Iterating = true; { for (int i = 0; i < m_Fibers.Count; ++i) { Fiber myFiber = m_Fibers[i]; m_Manager.Frame.RefreshTimeScale(); if (!myFiber.Update()) { m_Fibers.RemoveAt(i--); if (m_Race) { m_Iterating = false; return(false); } } } } m_Iterating = prevIterating; } return(m_Fibers.Count > 0); } return(false); }
bool IEnumerator.MoveNext() { if (m_Enumerator != null) { m_Fiber = m_Manager.ChainFiber(m_Enumerator); m_Fiber.SetNestedOwner(this); m_Fiber.SetParentFiber(m_ParentFiber); m_Enumerator = null; } if (m_Fiber != null) { if (m_Iterating) { return(true); } m_Iterating = true; { m_Accumulation += Routine.DeltaTime; if (m_Accumulation > m_Interval) { // It's important that we reset timescale here. // Otherwise timescale gets applied twice, resulting in inaccurate delta time values float oldUnscaledTime = m_Manager.Frame.UnscaledDeltaTime; float oldTimeScale = m_Manager.Frame.TimeScale; m_Manager.Frame.UnscaledDeltaTime = m_Accumulation; m_Manager.Frame.TimeScale = 1; m_Manager.Frame.RefreshTimeScale(); m_Accumulation = 0; bool bNext = m_Fiber.Update(); m_Manager.Frame.UnscaledDeltaTime = oldUnscaledTime; m_Manager.Frame.TimeScale = oldTimeScale; m_Manager.Frame.RefreshTimeScale(); if (!bNext) { m_Fiber = null; m_Iterating = false; return(false); } } } m_Iterating = false; return(true); } return(false); }
public bool OnRoutineStart() { for (int i = 0; i < m_Enumerators.Length; ++i) { if (m_Enumerators[i] != null) { m_Fibers.Add(m_Manager.ChainFiber(m_Enumerators[i])); } m_Enumerators[i] = null; } m_Enumerators = null; return(m_Fibers.Count > 0); }