Hello, I'm trying to make a tutorial in game. One that explains how to work the basics of the game. I want it to stop the game when the character reaches a certain point and have some text come up telling what to do and then start again when the player hits a button on the keyboard. Right now I'm trying to use a case switch but I'm not sure if that will work. Here's what I have so far:
using UnityEngine;
using System.Collections;
public class Tutorial : MonoBehaviour
{
int tut_state;
const int state_1 = 1;
const int state_2 = 2;
const int state_3 = 3;
const int state_4 = 4;
const int state_5 = 5;
const int state_6 = 6;
const int state_7 = 7;
const int state_8 = 8;
string display_text;
public string welcome;
public string moving;
public string pickUps;
public string shooting;
public string doors;
public string floating;
public string state7;
public string state8;
private bool beginTut = false;
private bool endTut = false
;
bool showGUI = false;
Rect display_box = new Rect(0,0, 200,200);
// Use this for initialization
void Start ()
{
}
void OnTriggerEnter()
{
if(!endTut)
{
beginTut = true;
showGUI = true;
}
}
// Update is called once per frame
void Update ()
{
if(!endTut && beginTut)
{
Time.timeScale = 0;
}
if(endTut)
{
Time.timeScale = 1;
showGUI = false;
}
}
void OnGUI()
{
switch(tut_state)
{
case state_1:
display_text = welcome;
break;
case state_2:
display_text = moving;
break;
case state_3:
display_text = pickUps;
break;
case state_4:
display_text = shooting;
break;
case state_5:
display_text = doors;
break;
case state_6:
display_text = floating;
break;
case state_7:
display_text = state7;
break;
case state_8:
display_text = state8;
break;
}
GUI.Label(display_box, display_text);
if(Input.GetKeyDown(KeyCode.B))
{
tut_state++;
}
}
}
Any help would be appreciated! Thanks!!
↧