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

        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
    }