FIZIXAgency

Unity 3D State Manager: Gamestart C# Script

Aug 29th, 2012
2,530
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     Unity 3D: Game Start Script Source for State Manager
  3.        
  4.     Copyright 2012 FIZIX Digital Agency
  5.     http://www.fizixstudios.com
  6.        
  7.     For more information see the tutorial at:
  8.     http://www.fizixstudios.com/labs/do/view/id/unity-game-state-manager
  9.        
  10.        
  11.     Notes:
  12.         This script is a basic GUI script to create a new game state; you will need the statemanager.cs
  13.         script.
  14. */
  15.  
  16. using UnityEngine;
  17. using System.Collections;
  18.  
  19. public class gamestart : MonoBehaviour
  20. {
  21.  
  22.        
  23.     // Our Startscreen GUI
  24.     void OnGUI ()
  25.     {
  26.         if (GUI.Button (new Rect (30, 30, 150, 30), "Start Game"))
  27.         {
  28.             startGame();
  29.         }
  30.     }
  31.    
  32.     private void startGame()
  33.     {
  34.         print("Starting game");
  35.        
  36.         DontDestroyOnLoad(gamestate.Instance);
  37.         gamestate.Instance.startState();   
  38.     }
  39. }
RAW Paste Data