//싱글톤 인스턴스가 사라졌을 때 protected virtual void OnDestroy() { //유일한 Instance가 자신이면, Instance값을 비워줌 (다른 인스턴스가 들어갈 수 있도록) if (Instance == this) { Instance = null; } }
protected override void Awake() { base.Awake(); if (Instance == null) { Instance = this; } else { Destroy(gameObject); } }