Time for action – linking your tutorial to your game
Your tutorial level is ready to play, but we still need a way to access it. We'll accomplish this by adding another button to your title screen directly underneath the start button. Perform the following steps to link the tutorial:
Open the scene named
TitleScreen
and double-click on theStartButton.cs
script to open it in your code editor.Add the following lines of code in your
OnGUI
function to create a tutorial button immediately below the start button:void OnGUI() { if(GUI.Button(new Rect(Screen.width / 2 – 50, Screen.height / 2 + 25, 100, 50), "Start")) { Application.LoadLevel("level1"); } //create a tutorial button if(GUI.Button(new Rect(Screen.width / 2 – 50, Screen.height / 2 + 125, 100, 50), "Tutorial")) { Application.LoadLevel("TutorialScreen"); } }
Much like the start and reset buttons, the code for the tutorial button is uniform with the others; we only needed to edit the button text and the linked level...