Advertisement
infinite_ammo

Global.cs

Sep 8th, 2012
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Global : MonoBehaviour
  5. {
  6.     private static Global instance;
  7.  
  8.     void Awake()
  9.     {
  10.         if (!instance)
  11.         {
  12.             instance = this;
  13.             DontDestroyOnLoad(gameObject);
  14.             InitFirst();
  15.         }
  16.         else
  17.         {
  18.             Destroy(gameObject);
  19.         }
  20.     }
  21.  
  22.     void Start()
  23.     {
  24.         InitScene();
  25.     }
  26.  
  27.     void OnLevelWasLoaded()
  28.     {
  29.         InitScene();
  30.     }
  31.  
  32.     void InitFirst()
  33.     {
  34.         // ...
  35.     }
  36.  
  37.     void InitScene()
  38.     {
  39.         // ...
  40.     }
  41.  
  42.     // public static functions here:
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement