Exemplo n.º 1
0
 protected void OnDestroy()
 {
     if (singleton == this)
     {
         singleton = null;
     }
 }
Exemplo n.º 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);
        }
    }
Exemplo n.º 3
0
 void Awake()
 {
     instance = this;
 }