private void OnDestroy() { // If we were the singleton, then clear the reference as we are being destroyed: if (_instance == this) { _instance = null; } }
private void Awake() { // Make sure we will only ever have one of these objects: if (_instance == null) { _instance = this; } else { Destroy(this); } }