Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Unity 3D: Level GUI Script Source for State Manager
- Copyright 2012 FIZIX Digital Agency
- http://www.fizixstudios.com
- For more information see the tutorial at:
- http://www.fizixstudios.com/labs/do/view/id/unity-game-state-manager
- Notes:
- This script is a C# script provides a simple GUI that interfaces with the state manager, you
- will need the statemanager.cs script and should review the gamestart.cs script for information
- on how to implement the state manager.
- */
- using UnityEngine;
- using System.Collections;
- public class levelgui : MonoBehaviour {
- // Initialize level
- void Start ()
- {
- print ("Loaded: " + gamestate.Instance.getLevel());
- }
- // ---------------------------------------------------------------------------------------------------
- // OnGUI()
- // ---------------------------------------------------------------------------------------------------
- // Provides a GUI on level scenes
- // ---------------------------------------------------------------------------------------------------
- void OnGUI()
- {
- // Create buttons to move between level 1 and level 2
- if (GUI.Button (new Rect (30, 30, 150, 30), "Load Level 1"))
- {
- gamestate.Instance.setLevel("Level 1");
- Application.LoadLevel("level1");
- }
- if (GUI.Button (new Rect (300, 30, 150, 30), "Load Level 2"))
- {
- print ("Moving to level 2");
- gamestate.Instance.setLevel("Level 2");
- Application.LoadLevel("level2");
- }
- // Output stats
- GUI.Label(new Rect(30, 100, 400, 30), "Name: " + gamestate.Instance.getName());
- GUI.Label(new Rect(30, 130, 400, 30), "HP: " + gamestate.Instance.getHP().ToString());
- GUI.Label(new Rect(30, 160, 400, 30), "MP: " + gamestate.Instance.getMP().ToString());
- }
- }
RAW Paste Data