Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Menu2 : MonoBehaviour {
- // tyyliasetukset
- public GUISkin menuSkin;
- // menu sijainti näytöllä
- public Rect menuArea;
- // menun sijainnin normalisointi -> resoluutio riippumaton
- Rect menuAreaNormalized;
- // muuttujat nappeja varten
- public Rect playButton;
- public Rect settingsButton;
- public Rect quitButton;
- void OnGUI()
- {
- // asetetaan tyylit GUI:lle
- GUI.skin = menuSkin;
- // valikko alkaa
- GUI.BeginGroup(menuArea);
- if (GUI.Button(new Rect(playButton), "Play"))
- {
- }
- if (GUI.Button(new Rect(settingsButton), "Settings"))
- {
- }
- if (GUI.Button(new Rect(quitButton), "Quit"))
- {
- StartCoroutine("ButtonAction", "quit");
- }
- // valikko loppu
- GUI.EndGroup();
- }
- // nappien toiminnallisuus
- //ladattavan kentän nimi tai quit
- IEnumerator ButtonAction(string levelToLoad)
- {
- yield return new WaitForSeconds(0.5f);
- if (levelToLoad != "quit")
- {
- Application.LoadLevel(levelToLoad);
- }
- else
- {
- Application.Quit();
- Debug.Log("Application has quit");
- }
- }
- }
Add Comment
Please, Sign In to add comment