internal void Resume(MonoBehaviour behaviour) { if (_state != RadicalCoroutineOperatingState.Inactive && _state != RadicalCoroutineOperatingState.Paused) throw new System.InvalidOperationException("Failed to start RadicalCoroutine. The Coroutine is already being processed."); if (behaviour == null) throw new System.ArgumentNullException("behaviour"); _state = RadicalCoroutineOperatingState.Active; _owner = behaviour; if (_stack.CurrentOperation is IPausibleYieldInstruction) (_stack.CurrentOperation as IPausibleYieldInstruction).OnResume(); #if SP_LIB var manager = behaviour.AddOrGetComponent<RadicalCoroutineManager>(); #else var manager = behaviour.GetComponent<RadicalCoroutineManager>(); if (manager == null) manager = behaviour.gameObject.AddComponent<RadicalCoroutineManager>(); #endif _manager = manager; _manager.RegisterCoroutine(this); _token = behaviour.StartCoroutine(this); }
public void StartAsync(MonoBehaviour behaviour, RadicalCoroutineDisableMode disableMode = RadicalCoroutineDisableMode.Default) { if (_state != RadicalCoroutineOperatingState.Inactive) throw new System.InvalidOperationException("Failed to start RadicalCoroutine. The Coroutine is already being processed."); if (behaviour == null) throw new System.ArgumentNullException("behaviour"); _state = RadicalCoroutineOperatingState.Active; _owner = behaviour; _disableMode = disableMode; if (_stack.CurrentOperation is IPausibleYieldInstruction) (_stack.CurrentOperation as IPausibleYieldInstruction).OnResume(); _stack.Push(com.spacepuppy.Async.RadicalTask.Create(this)); //we start the task as an async operation #if SP_LIB var manager = behaviour.AddOrGetComponent<RadicalCoroutineManager>(); #else var manager = behaviour.GetComponent<RadicalCoroutineManager>(); if (manager == null) manager = behaviour.gameObject.AddComponent<RadicalCoroutineManager>(); #endif _manager = manager; _manager.RegisterCoroutine(this); _token = behaviour.StartCoroutine(this); }