void Awake() { if (instances.GetValueOrDefault(GetType(), null) == null) { instances.AddOrReplace(GetType(), this); } else { Destroy(this.gameObject); } DontDestroyOnLoad(this.gameObject); }