// Start is called before the first frame update void Awake() { //원래 인스턴스가 없었다면, 즉 사용자가 있는 방이 처음 접속한 방이라면, if (s_Instance == null) { Debug.Log("sInstance: null"); //인스턴스를 새로 생성하도록 하고, s_Instance = this; } else //원래 인스턴스가 있었다면, 즉 사용자가 어디론가 옮겨왔다면, { Debug.Log("sInstance: not null"); //이 오브젝트를 삭제하고 그 오브젝트를 쓰도록 한다. Destroy(this.gameObject); return; } DontDestroyOnLoad(this.gameObject); }
void OnApplicationQuit() { s_Instance = null; }