/// <summary> /// Only ever called once, mainly used to initialize variables. /// </summary> private void Awake() { if (Instance != null) { Destroy(Instance.gameObject); } DontDestroyOnLoad(this); Instance = this; }
/// <summary> /// Called when the script is being destroyed. /// </summary> private void OnDestroy() { Instance = null; }