I’ve made a very simple tutorial world and added a script in. This script takes care for the whole tutorial. When the player joins the world for the first time their Time.timeScale is equal to 0. Now a GUI pops-up, explaining them how to move and attack. Once they press the ‘return’ key their Time.timeScale will be set to equal 1 again. Now my question is: How do I make that GUI dissappear as soon as they hit enter?
using UnityEngine;
using System.Collections;
public class TutorialMenu : MonoBehaviour {
public void OnLevelWasLoaded(int level) {
if(level == 1) {
Time.timeScale = 0;
}
}
//Player Joins World for the First Time.
void OnGUI1() {
GUI.Label(new Rect(10, 10, 200, 700), "Welcome to Bow Brothers. In this tutorial we will teach you how to: Move, attack, loot and simple basic gamemechanics. See the cube infront of you? He's about to attack you. To attack back use the left mousebutton. You move around using the WASD keys. Press the 'Return' key to continue.");
}
//Player Killed the Cube and is now asked to loot the Cube.
void OnGUI2() {
GUI.Label(new Rect(10, 10, 200, 700), "Good job. Now walk up to the cube and press E to loot.");
}
//Player looted the Cube, and is now asked to cut down that tree in the Tutorial world.
void OnGUI3() {
GUI.Label(new Rect(10, 10, 200, 700), "Seems like you've found yourself an axe. Axes can be used to cut trees. Cutting trees will be essential for your survival. You will be able to make bows and arrows from the wood you cut. Also wood will provide you campfires. And wood is also used to build your owns house. Now cut down that tree.");
}
public void BringUpExplenation() {
if(Time.timeScale == 0) {
OnGUI1();
}
}
public void StartUpGameAgain() {
if(Input.GetKeyUp(KeyCode.Return))
Time.timeScale = 1;
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
BringUpExplenation();
StartUpGameAgain();
}
}