Exemplo n.º 1
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Exemplo n.º 2
0
    void playMusic()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
        }

        DontDestroyOnLoad(this.gameObject);
    }
Exemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     if (musicMenu == null)
     {
         //if not, set instance to this
         musicMenu = this;
         //If instance already exists and it's not this:
     }
     else if (musicMenu != this)
     {
         //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
         Destroy(gameObject);
     }
     if (GameObject.Find("gameMusic"))
     {
         Destroy(GameObject.Find("gameMusic"));
     }
     //Sets this to not be destroyed when reloading scene
     DontDestroyOnLoad(gameObject);
 }
Exemplo n.º 4
0
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
        }
        DontDestroyOnLoad(this.gameObject);

        sounds = GetComponents <AudioSource>();
        music  = sounds[0];
        //if (!AudioBegin)
        //{
        music.Play();
        DontDestroyOnLoad(gameObject);
        //    AudioBegin = true;
        //}
    }