Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using JeffreyStephens.Weapons;
- using UnityEngine;
- namespace JeffreyStephens.Game
- {
- public class GameManager : MonoBehaviour
- {
- private static bool _applicationIsQuitting = false;
- private static GameManager _Instance;
- public static GameManager Instance
- {
- get
- {
- if ( _applicationIsQuitting ) return null;
- if ( _Instance == null )
- {
- GameObject instanceGameObject = GameObject.Find ( "GameManager" );
- if ( instanceGameObject == null )
- instanceGameObject = new GameObject ( "GameManager", typeof ( GameManager ) );
- if ( UnityEditor.EditorApplication.isPlaying )
- DontDestroyOnLoad ( instanceGameObject );
- _Instance = instanceGameObject.GetComponent<GameManager> ( );
- }
- return _Instance;
- }
- }
- [Header ( "GameManager Variables" )]
- public WeaponManager WeaponManager;
- // ------------------------------------------------------------------------------- Unity Functions
- void Awake ( )
- {
- if ( GameManager.Instance != this )
- Destroy ( this );
- }
- void OnDestroy ( )
- {
- _applicationIsQuitting = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment