In Game Tutorial

I am trying to create an in game tutorial for my game, but was wondering about a better way to approach it then my current solution. I currently have a set of bools in my Tutorial script that control which part of the tutorial is shown at what point, and then waiting for the player to click a button to change over to the next tutorial bool. I was thinking of using an enum, but that would result in having a different value for that enum for each tutorial “section”/screen, and still the same amount of code work.

I thought of using some kind of IEnumerator, but got stuck trying to figure out having it display GUI.Box (currently used to display tutorial info), and a “continue” button, or taking in userInput, or even an “exit tutorial” button to end the tutorial.

for some reason I feel I am making this harder then it is, but any help would be greatly appreciated.

If your tutorial consists of a GUI.Box and level dependent stuff in it, then you should create a very simple state machine with coroutines, and have a boolean flag determining whether or not show the Box.

I’m thinking:

	string tutorialText;
	bool stayInTutorial;
	IEnumerator Tutorial(){
		yield return Tutorial1();
		yield return Tutorial2();
	IEnumerator Tutorial1(){
		tutorialText = "This is the 1st tutorial.";
			yield return null;
		stayInTutorial = true;

You would have a button somewhere to move to the next tutorial, simply by setting stayIntutorial to false. Then you can show it whenever you want by printing out tutorialText and whatever else you want to show. If you want to completely exit the tutorial just CloseCoroutine(“Tutorial”);, assuming you have started it with StartCoroutine(string);

Moving backwards or skipping tutorials in this machine is hard, but with some creativity, certainly possible.

You could try making separate levels that get loaded additively:


Or some variation thereof. Then rather having a bool to switch things on and off, you can have objects created en masse when you want them, without having to manage the instantiation of each object.

You could use a statemachine.