예제 #1
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         DestroyImmediate(this);
     }
 }
예제 #2
0
    void Awake()
    {
        if (singleton != null)
        {
            DestroyImmediate(gameObject);
            return;
        }

        singleton = this;

        DontDestroyOnLoad(gameObject);
    }
예제 #3
0
    // Start is called before the first frame update
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }


        else
        {
            instance = this;
            GameObject.DontDestroyOnLoad(gameObject);
        }
    }
예제 #4
0
    void Awake()
    {
        //if we don't have an [_instance] set yet
        if (!_instance)
        {
            _instance = this;
        }
        //otherwise, if we do, kill this thing
        else
        {
            Destroy(this.gameObject);
        }


        DontDestroyOnLoad(this.gameObject);
    }