void TestSingleton() { if (instance != null) { Destroy(gameObject); return; } instance = this; DontDestroyOnLoad(gameObject); }
void Awake() { if (instance == null) { DontDestroyOnLoad(this.gameObject); instance = this; } else if (instance != this) { Destroy(this.gameObject); } }