Hi,
I am calling a photon RPC Coroutine from within another unity Coroutine.
I need the execution of the unity Coroutine to pause “i.e. Yield Return” until the Photon Coroutine has finished execution, but yield return does not work when calling a Photon RPC
In the code example below you can see how unity would ordinarily pause execution in the 2nd statement by using yield return StartCoroutine().
But how do I achieve the same for the 1st Statement where I call Photon RPC Coroutine?
private IEnumerator GameLoop ()
{
// Start off by running the 'RoundStarting' coroutine but don't return until fin
view.RPC("RoundStarting", RpcTarget.AllBufferedViaServer);
// Once the 'RoundStarting' fin run 'RoundPlaying' but don't return until fin
yield return StartCoroutine (RoundPlaying());
// Once execution has returned here, run the 'RoundEnding'
yield return StartCoroutine (RoundEnding());
// This code is not run until 'RoundEnding' has finished.
if (m_GameWinner != null)
{
// If there is a game winner, restart the level.
SceneManager.LoadScene (1);
}
else
{
// If there isn't a winner yet, restart this coroutine so the loop continues.
StartCoroutine (GameLoop ());
}
}