void Awake()
 {
     // Singleton manager
     if (p_instance == null)
     {
         p_instance = this;
     }
     else if (p_instance != this)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 2
0
    void Awake()
    {
        // ===>> SingletonMAnager

        //Check if instance already exists
        if (p_instance == null)
        {
            //if not, set instance to this
            p_instance = this;
        }
        //If instance already exists and it's not this:
        else if (p_instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }
        //Sets this to not be destroyed when reloading scene
        // DontDestroyOnLoad(gameObject);   par nécessaire ici car déja fait par script __DDOL sur l'objet _EGO_app qui recueille tous les mgr
    }