//Awake is always called before any Start functions
    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


        // ====> vérifier si les scènes passées en paramètres existent
        // ====> les stocke dans un dictionnaire
        p_arr_Scenes = new string[arr_SceneName.Length];
        p_nbScenes   = 0;

        foreach (string _scene_name in arr_SceneName)
        {
            p_arr_Scenes[p_nbScenes] = _scene_name;                 // la scène sera accessible avec son indice
            p_nbScenes++;

            p_list_Scenes.Add(_scene_name);              // la scène sera accessible avec son indice
            p_dict_Scenes.Add(_scene_name, _scene_name); // la scène sera accessible avec son NOM
        }
    }
    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);
        }

        DontDestroyOnLoad(gameObject);
    }
Exemple #3
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
    }