void OnDestroy() { // Only set sInstance to null if the actual instance is destroyed. if (sInstance == this) { sInstance = null; } }
private void Awake() { if (sInstance == null) { sInstance = this; } else if (sInstance != this) { Destroy(this.gameObject); return; } }