private GWait CastWaitOrder(object returnObject) { GWait waitOrder = null; if (returnObject == null) { waitOrder = new GWait(GTimeUnit.Frame, 1); } else { if (returnObject is GWait) { waitOrder = (GWait)returnObject; } else if (returnObject is IEnumerator) { IEnumerator coroutine = (IEnumerator)returnObject; GRoutine targetRoutine = ownerCore.AddGRoutine(coroutine); delayRoutine = targetRoutine; } else if (routine.Current is GRoutine) { GRoutine targetRoutine = (GRoutine)returnObject; delayRoutine = targetRoutine; } else { GDebug.Log("지원되지 않는 반환 형식입니다. 'GWait', 'GRoutine', 'IEnumerator' 클래스를 반환하세요.", GLogLevel.Error); waitOrder = new GWait(GTimeUnit.Frame, 1); } } return(waitOrder); }
internal bool Run(float deltaMillisec) { try { if (UpdateTime(deltaMillisec)) { return(true); } if (delayMillisec <= 0f) { bool hasValue = routine.MoveNext(); if (hasValue) { object returnObject = routine.Current; GWait waitOrder = CastWaitOrder(returnObject); if (waitOrder != null) { switch (waitOrder.unit) { case GTimeUnit.Frame: delayFrame += (int)waitOrder.time; break; case GTimeUnit.Millisecond: delayMillisec += waitOrder.time; break; case GTimeUnit.Second: delayMillisec += waitOrder.time * 1000f; break; } } } else { Complete(); } return(hasValue); } return(true); } catch (Exception ex) { GDebug.Log(ex.ToString(), GLogLevel.Error); Complete(); return(false); } }