Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma strict
- var selection: int;
- function Start () {
- selection = 0;
- }
- function Update ()
- {
- if(Input.GetKeyDown(KeyCode.DownArrow))
- {
- selection++;
- }
- else if(Input.GetKeyDown(KeyCode.UpArrow))
- {
- selection--;
- }
- switch(selection)
- {
- case -1:
- selection = 2;
- break;
- case 0:
- //new game highlighted
- if(Input.GetKeyDown(KeyCode.Space))
- {
- NewGame();
- }
- break;
- case 1:
- //load game highlighted
- if(Input.GetKeyDown(KeyCode.Space))
- {
- LoadGame();
- }
- break;
- case 2:
- //exit game highlighted
- if(Input.GetKeyDown(KeyCode.Space))
- {
- ExitGame();
- }
- break;
- case 3:
- selection = 0;
- break;
- }
- }
- function OnGUI()
- {
- if(selection == 0)
- {
- GUI.color = Color.yellow;
- GUI.Button(Rect(5,5,100,30),"New Game");
- GUI.color = Color.white;
- GUI.Button(Rect(5,35,100,30),"Load Game");
- GUI.color = Color.white;
- GUI.Button(Rect(5,65,100,30),"Exit");
- }
- else if (selection == 1)
- {
- GUI.color = Color.white;
- GUI.Button(Rect(5,5,100,30),"New Game");
- GUI.color = Color.yellow;
- GUI.Button(Rect(5,35,100,30),"Load Game");
- GUI.color = Color.white;
- GUI.Button(Rect(5,65,100,30),"Exit");
- }
- else if(selection == 2)
- {
- GUI.color = Color.white;
- GUI.Button(Rect(5,5,100,30),"New Game");
- GUI.color = Color.white;
- GUI.Button(Rect(5,35,100,30),"Load Game");
- GUI.color = Color.yellow;
- GUI.Button(Rect(5,65,100,30),"Exit");
- }
- }
- function NewGame()
- {
- //new game
- Debug.Log("New Game");
- }
- function LoadGame()
- {
- //load game
- Debug.Log("Load Game");
- }
- function ExitGame()
- {
- //exit game
- Debug.Log("Exit Game");
- }
Advertisement
Add Comment
Please, Sign In to add comment