void Awake() { if (self != null && this != self) { Destroy(this.gameObject); return; } else { self = this; DontDestroyOnLoad(gameObject); } }
// Start is called before the first frame update void Start() { DontDestroyOnLoad(this); if (obj == null) { obj = this; DontDestroyOnLoad(this); } else { Object.Destroy(gameObject); } }