Exemple #1
0
 protected void OnDestroy()
 {
     if (singleton == this)
     {
         singleton = null;
     }
 }
Exemple #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);
        }
    }
 void Awake()
 {
     instance = this;
 }