//Set the instance to null ondestroy void OnDestroy() { if (Instance == this) { Instance = null; } }
void Awake() { if (Instance == null) { //if not, set it to this. Instance = this; DontDestroyOnLoad(gameObject); } else if (Instance != this && Instance != null) { Destroy(gameObject); } }