Guest User

Untitled

a guest
Jun 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class DelegateTry : MonoBehaviour {
  5.  
  6. private delegate void TryDelegate();
  7. private TryDelegate menuFunction;
  8.  
  9.  
  10. private float screenHeight;
  11. private float screenWidth;
  12. private float buttonHeight;
  13. private float buttonWidth;
  14.  
  15.  
  16.  
  17.  
  18. // Use this for initialization
  19. void Start () {
  20.  
  21. screenHeight = Screen.height;
  22. screenWidth = Screen.width;
  23.  
  24.  
  25. buttonHeight = screenHeight * 0.2f;
  26. buttonWidth = screenWidth * 0.3f;
  27.  
  28. menuFunction = anyKey;
  29. }
  30.  
  31. void OnGUI()
  32. {
  33. menuFunction();
  34. }
  35.  
  36. void anyKey()
  37. {
  38. if (Input.anyKey)
  39. {
  40. menuFunction = mainMenu;
  41. }
  42.  
  43. GUI.skin.label.alignment = TextAnchor.MiddleCenter;
  44.  
  45. GUI.Label(new Rect(screenWidth * 0.45f, screenHeight * 0.45f, screenWidth * 0.1f, screenHeight * 0.1f), ("Press Any Key To Continue"));
  46. }
  47.  
  48. void mainMenu()
  49. {
  50. if (GUI.Button(new Rect((screenWidth - buttonWidth) * 0.5f, screenHeight * 0.1f, buttonWidth, buttonHeight), "Start Game"))
  51. {
  52. Application.LoadLevel("StartUp");
  53. }
  54. if (GUI.Button(new Rect((screenWidth - buttonWidth) * 0.5f, screenHeight * 0.5f, buttonWidth, buttonHeight), "Start Game"))
  55. {
  56. Application.Quit();
  57. }
  58.  
  59. }
  60.  
  61.  
  62. }
Add Comment
Please, Sign In to add comment