Loop Coroutine For A Demo Mode

I’m working on doing a demo mode and I’ve come up with this method for looping a coroutine. I’m just curious??? Is this an OK method to use or should I be using something different??
my little demo project seems to work OK… but just what to get some of you more experienced people’s opinion on this method.

Thanks. :slight_smile:
Here is my WIP proof of concept script.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class demoLoop : MonoBehaviour {

	public GameObject ImageOne;
	public GameObject ImageTwo;

	public GameObject SounderObj;

	public AudioClip Voice01;


	public bool DemoMode = false;


	public void SetDemoModeOnOff()
	{
		if (DemoMode == false) 
		{
			DemoMode = true;
		}
		else if (DemoMode == true) 
		{
			DemoMode = false;
		}
	}



	public void PlayDemoOne()
	{
		StartCoroutine(StartDemoOne());
	}


	IEnumerator StartDemoOne()
	{
		yield return new WaitForSeconds(2.0f); // wait time

		if (DemoMode == true) 
		{
			yield return new WaitForSeconds(1.5f); // wait time
			ImageOne.SetActive(true);

			yield return new WaitForSeconds(3.5f); // wait time
			ImageOne.SetActive(false);
			ImageTwo.SetActive(true);

			yield return new WaitForSeconds(3.5f); // wait time
			SounderObj.GetComponent<AudioSource>().PlayOneShot (Voice01, 1);

			yield return new WaitForSeconds(3.5f); // wait time
			ImageTwo.SetActive(false);
			PlayDemoOne ();
		}
	}


}

Your method is ok. You can simplified your loop to

` IEnumerator StartDemoOne()
{

     while (DemoMode == true) 
     {
         yield return new WaitForSeconds(2.0f); // wait time
         if (DemoMode == false)
               yield break;

         yield return new WaitForSeconds(1.5f); // wait time
         ImageOne.SetActive(true);

         yield return new WaitForSeconds(3.5f); // wait time
         ImageOne.SetActive(false);
         ImageTwo.SetActive(true);

         yield return new WaitForSeconds(3.5f); // wait time
         SounderObj.GetComponent<AudioSource>().PlayOneShot (Voice01, 1);

         yield return new WaitForSeconds(3.5f); // wait time
         ImageTwo.SetActive(false);
         //PlayDemoOne (); --> no need to start coroutine again
     }
 }`