Пример #1
0
 protected void OnDestroy()
 {
     if (singleton == this)
     {
         singleton = null;
     }
 }
Пример #2
0
    protected void Awake()
    {
        // Awake is for initialisation and connecting scripts!!!

        // Check if there is already a singleton instance
        if (singleton == null)
        {
            singleton = this;
            DontDestroyOnLoad(singleton);
            init();
        }
        else
        {
            //if there already was one, destroy this new instance again
            Destroy(this);
        }
    }
Пример #3
0
 void Awake()
 {
     instance = this;
 }