Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class DelegateTry : MonoBehaviour {
- private delegate void TryDelegate();
- private TryDelegate menuFunction;
- private float screenHeight;
- private float screenWidth;
- private float buttonHeight;
- private float buttonWidth;
- // Use this for initialization
- void Start () {
- screenHeight = Screen.height;
- screenWidth = Screen.width;
- buttonHeight = screenHeight * 0.2f;
- buttonWidth = screenWidth * 0.3f;
- menuFunction = anyKey;
- }
- void OnGUI()
- {
- menuFunction();
- }
- void anyKey()
- {
- if (Input.anyKey)
- {
- menuFunction = mainMenu;
- }
- GUI.skin.label.alignment = TextAnchor.MiddleCenter;
- GUI.Label(new Rect(screenWidth * 0.45f, screenHeight * 0.45f, screenWidth * 0.1f, screenHeight * 0.1f), ("Press Any Key To Continue"));
- }
- void mainMenu()
- {
- if (GUI.Button(new Rect((screenWidth - buttonWidth) * 0.5f, screenHeight * 0.1f, buttonWidth, buttonHeight), "Start Game"))
- {
- Application.LoadLevel("StartUp");
- }
- if (GUI.Button(new Rect((screenWidth - buttonWidth) * 0.5f, screenHeight * 0.5f, buttonWidth, buttonHeight), "Start Game"))
- {
- Application.Quit();
- }
- }
- }
Add Comment
Please, Sign In to add comment