How can I manually continue coroutines?

I’m trying to write a manager that “ticks” the AI (movement and attack) of the beings in my game.
I want to centralise this so I can easily slow down and speed up time (and thus the speed of gameplay)
I write my AI using coroutines and yield to save state between calls, but I don’t know how to manually continue them.
I’m used to using StartCoroutine and having Unity call them each Update step.

How can I continue yield-ed methods manually?

Here’s my code if it helps:

public class TickManager : MonoBehaviour
{
	public List<TickAI> m_beings = new List<TickAI>();

	public float m_updateDelay;
	float m_waitLeft = 0;

	void Update()
	{
		m_waitLeft -= Time.deltaTime;
		if (m_waitLeft <= 0)
		{
			m_waitLeft += m_updateDelay;

			Debug.Log("Tick");

			for (int i = 0; i < m_beings.Count; i++)
			{
				m_beings*.Tick();*
  •   		}*
    
  •   	}*
    
  •   }*
    
  • }*
  • public class TickAI : MonoBehaviour*
  • {*
  •   // Coroutine-style state machine, using yield*
    
  •   public IEnumerator Tick()*
    
  •   {*
    
  •   	while (true)*
    
  •   	{*
    
  •   		if (HasDestination)*
    
  •   		{*
    
  •   			while (!ReachedDestination) {*
    
  •   				MovementTick();*
    
  •   				yield return null;*
    
  •   			}*
    
  •   		}*
    
  •   		else*
    
  •   		{*
    
  •   			if (HasTarget)*
    
  •   			{		*
    
  •   				// Start multi-step behaviour*
    
  •   				StartCoroutine(AttackBehaviour());*
    
  •   			}*
    
  •   		}*
    
  •   		yield return null;*
    
  •   	}*
    
  •   }*
    
  • }*

Nevermind I think I got it. In my TickManager I just call Tick().MoveNext() to run the coroutine until the next yield statement. It’s just an iterator anyway.

This helped me: http://www.altdevblogaday.com/2011/07/07/unity3d-coroutines-in-detail/

In MonoBehaviour, there is no such PauseCourtine, ContinueCourtine, so you can consider that use StopCourtine first then StartCourtine again.