示例#1
0
    public void PauseResumeInfiniteCoroutine()
    {
        if (_infiniteCoroutine != null)
        {
            switch (_infiniteCoroutine.State)
            {
            case JBYieldInstruction.YieldStateType.Running:
                _infiniteCoroutine.Pause();
                break;

            case JBYieldInstruction.YieldStateType.Paused:
                _infiniteCoroutine.Resume();
                break;

            case JBYieldInstruction.YieldStateType.Stopped:
            case JBYieldInstruction.YieldStateType.Finished:
            case JBYieldInstruction.YieldStateType.CaughtException:
                throw new Exception("This should never happen on this coroutine test");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        else
        {
            Debug.Log("Started new infinite coroutine");
            _timeSinceLastPulse              = Time.time;
            _infiniteCoroutine               = StartJellyCoroutine(InfiniteCoroutine());
            _infiniteCoroutine.StateChanged +=
                (instruction, type) => Debug.Log(string.Format("Infinite coroutine new state: {0}", type));
        }
    }
        /// <summary>
        ///     Starts a Jelly Coroutine that doesn't return a value
        /// </summary>
        /// <param name="coroutine">IEnumerator to run - Notice, you must use Jelly YieldStatements, Unity's won't work here</param>
        /// <returns>A started & running coroutine</returns>
        public JellyCoroutine StartCoroutine(IEnumerator routine)
        {
            var coroutine = new JellyCoroutine(routine);

            coroutine.StateChanged += CoroutineOnStateChanged;
            coroutine.Start();
            return(coroutine);
        }
示例#3
0
 public void StopInfiniteCoroutine()
 {
     if (_infiniteCoroutine == null)
     {
         return;
     }
     _infiniteCoroutine.Stop();
     _infiniteCoroutine = null;
 }