Advertisement
Guest User

Untitled

a guest
Sep 16th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;// we need this namespace in order to access UI elements within our script
  3. using System.Collections;
  4.  
  5. public class menuScript : MonoBehaviour
  6. {
  7. public Canvas quitMenu;
  8. public Button startText;
  9. public Button exitText;
  10.  
  11. void Start()
  12.  
  13. {
  14. quitMenu = quitMenu.GetComponent<Canvas> ();
  15. startText = startText.GetComponent<Button> ();
  16. exitText = exitText.GetComponent<Button> ();
  17. quitMenu.enabled = false;
  18.  
  19. }
  20.  
  21. public void ExitPress() //this function will be used on our Exit button
  22.  
  23. {
  24. quitMenu.enabled = true; //enable the Quit menu when we click the Exit button
  25. startText.enabled = false; //then disable the Play and Exit buttons so they cannot be clicked
  26. exitText.enabled = false;
  27.  
  28. }
  29.  
  30. public void NoPress() //this function will be used for our "NO" button in our Quit Menu
  31.  
  32. {
  33. quitMenu.enabled = false; //we'll disable the quit menu, meaning it won't be visible anymore
  34. startText.enabled = true; //enable the Play and Exit buttons again so they can be clicked
  35. exitText.enabled = true;
  36.  
  37. }
  38.  
  39. public void StartLevel () //this function will be used on our Play button
  40.  
  41. {
  42. Application.LoadLevel (1); //this will load our first level from our build settings. "1" is the second scene in our game
  43.  
  44. }
  45.  
  46. public void ExitGame () //This function will be used on our "Yes" button in our Quit menu
  47.  
  48. {
  49. Application.Quit(); //this will quit our game. Note this will only work after building the game
  50.  
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement