Advertisement
AnomalousUnderdog

Simple Menu

Jan 31st, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2.  
  3. var selection : int;
  4.  
  5. function Start()
  6. {
  7.     selection = 0;
  8. }
  9.  
  10. function Update()
  11. {
  12.     if (Input.GetKeyDown(KeyCode.DownArrow))
  13.     {
  14.         selection++;
  15.     }
  16.     else if (Input.GetKeyDown(KeyCode.UpArrow))
  17.     {
  18.         selection--;
  19.     }
  20.  
  21.     switch (selection)
  22.     {
  23.         case -1:
  24.             selection = 2;
  25.             break;
  26.        
  27.         case 0:
  28.             //new game highlighted
  29.             if(Input.GetKeyDown(KeyCode.Space))
  30.             {
  31.                 NewGame();
  32.             }
  33.             break;
  34.        
  35.         case 1:
  36.             //load game highlighted
  37.             if(Input.GetKeyDown(KeyCode.Space))
  38.             {
  39.                 LoadGame();
  40.             }
  41.             break;
  42.        
  43.         case 2:
  44.             //exit game highlighted
  45.             if(Input.GetKeyDown(KeyCode.Space))
  46.             {
  47.                 ExitGame();
  48.             }
  49.             break;
  50.        
  51.         case 3:
  52.             selection = 0;
  53.             break;
  54.     }
  55. }
  56.  
  57. function OnGUI()
  58. {
  59.     if (selection == 0)
  60.     {
  61.         GUI.color = Color.yellow;
  62.     }
  63.     else
  64.     {
  65.         GUI.color = Color.white;
  66.     }
  67.     GUI.Button(Rect(5,5,100,30),"New Game");
  68.  
  69.  
  70.     if (selection == 1)
  71.     {
  72.         GUI.color = Color.yellow;
  73.     }
  74.     else
  75.     {
  76.         GUI.color = Color.white;
  77.     }
  78.     GUI.Button(Rect(5,35,100,30),"Load Game");
  79.  
  80.  
  81.     if (selection == 2)
  82.     {
  83.         GUI.color = Color.yellow;
  84.     }
  85.     else
  86.     {
  87.         GUI.color = Color.white;
  88.     }
  89.     GUI.Button(Rect(5,65,100,30),"Exit");
  90. }
  91.  
  92.  
  93. function NewGame()
  94. {
  95.     //new game
  96.     Debug.Log("New Game");
  97. }
  98.  
  99. function LoadGame()
  100. {
  101.     //load game
  102.     Debug.Log("Load Game");
  103. }
  104.  
  105. function ExitGame()
  106. {
  107.     //exit game
  108.     Debug.Log("Exit Game");
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement