Guest User

Untitled

a guest
Feb 21st, 2015
40
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class MenuManager : MonoBehaviour {
  5.     /*
  6.     READ ME
  7.  
  8.     How to use:
  9.         Create a root object with this script
  10.         Make child objects under this script and assign the MenuScreen.cs on those objects
  11.         On button OnClick event call ChangeMenu on this script
  12.  
  13.     You can start the game on any scene with a Menu Manager
  14.  
  15.     Assign a Menu Screen object to First Screen to start with that screen
  16.  
  17.     Disable all gameObject with a MenuScreen.cs before run
  18.  
  19.     */
  20.     string MenuScreens;
  21.     public MenuScreen ActiveScreen;
  22.     public MenuScreen FirstScreen;
  23.     // Use this for initialization
  24.     void Awake () {
  25.         #if UNITY_EDITOR
  26.         if (SceneManager.Instance == null)
  27.             Application.LoadLevel(0);
  28.         #endif
  29.         FirstScreen.gameObject.SetActive (true);
  30.         ActiveScreen = FirstScreen;
  31.     }
  32.  
  33.     public void ChangeMenuAndFade (MenuScreen screen) {
  34.         StartCoroutine(ChangeScreen (screen, true));
  35.     }
  36.  
  37.     public void ChangeMenu (MenuScreen screen) {
  38.         StartCoroutine(ChangeScreen (screen, false));
  39.     }
  40.  
  41.     public void LoadScene (int index, bool animate) {
  42.         SceneManager.Instance.LoadLevelFadeInDelegate(index, animate);
  43.     }
  44.  
  45.     public void LoadScene (string name,  bool animate) {
  46.         SceneManager.Instance.LoadLevelFadeInDelegate(name);
  47.     }
  48.  
  49.     public void LoadSceneFadeIn (string name) {
  50.         SceneManager.Instance.LoadLevelFadeInDelegate(name);
  51.     }
  52.  
  53.     public void LoadScene (string name) {
  54.         SceneManager.Instance.LoadLevelFadeInDelegate(name, false);
  55.     }
  56.  
  57.     IEnumerator ChangeScreen (MenuScreen target, bool animate) {
  58.         if (animate) {
  59.             SceneManager.Instance.SetCanvasEnabled (true);
  60.             yield return StartCoroutine(SceneManager.Instance.PlayFadeAnimation (0f, 1f, SceneManager.Instance.blackOverlay));
  61.         }
  62.         ActiveScreen.gameObject.SetActive (false);
  63.         ActiveScreen = target;
  64.         ActiveScreen.gameObject.SetActive (true);
  65.         if (animate) {
  66.             yield return StartCoroutine(SceneManager.Instance.PlayFadeAnimation (1f, 0f, SceneManager.Instance.blackOverlay));
  67.             SceneManager.Instance.SetCanvasEnabled (false);
  68.         }
  69.     }
  70.  
  71.     public void QuitRequest () {
  72.         Application.Quit ();
  73.     }
  74.  
  75. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×