Guest User

Untitled

a guest
Jan 22nd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Menu2 : MonoBehaviour {
  5.  
  6. // tyyliasetukset
  7. public GUISkin menuSkin;
  8.  
  9. // menu sijainti näytöllä
  10. public Rect menuArea;
  11.  
  12. // menun sijainnin normalisointi -> resoluutio riippumaton
  13. Rect menuAreaNormalized;
  14.  
  15. // muuttujat nappeja varten
  16. public Rect playButton;
  17. public Rect settingsButton;
  18. public Rect quitButton;
  19.  
  20. void OnGUI()
  21. {
  22. // asetetaan tyylit GUI:lle
  23. GUI.skin = menuSkin;
  24.  
  25. // valikko alkaa
  26. GUI.BeginGroup(menuArea);
  27.  
  28. if (GUI.Button(new Rect(playButton), "Play"))
  29. {
  30. }
  31.  
  32. if (GUI.Button(new Rect(settingsButton), "Settings"))
  33. {
  34. }
  35.  
  36. if (GUI.Button(new Rect(quitButton), "Quit"))
  37. {
  38. StartCoroutine("ButtonAction", "quit");
  39. }
  40.  
  41. // valikko loppu
  42. GUI.EndGroup();
  43.  
  44. }
  45.  
  46. // nappien toiminnallisuus
  47. //ladattavan kentän nimi tai quit
  48. IEnumerator ButtonAction(string levelToLoad)
  49. {
  50. yield return new WaitForSeconds(0.5f);
  51.  
  52. if (levelToLoad != "quit")
  53. {
  54. Application.LoadLevel(levelToLoad);
  55. }
  56. else
  57. {
  58. Application.Quit();
  59. Debug.Log("Application has quit");
  60. }
  61.  
  62. }
  63.  
  64. }
Add Comment
Please, Sign In to add comment