Exemplo n.º 1
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Exemplo n.º 2
0
    void Awake()
    {
        if (instance != null && instance != this)
        {
            if (instance.GetComponent <AudioSource>().clip != GetComponent <AudioSource>().clip)
            {
                instance.GetComponent <AudioSource>().clip   = GetComponent <AudioSource>().clip;
                instance.GetComponent <AudioSource>().volume = GetComponent <AudioSource>().volume;
                instance.GetComponent <AudioSource>().Play();
            }

            Destroy(this.gameObject);
            return;
        }

        instance = this;
        GetComponent <AudioSource>().Play();
        DontDestroyOnLoad(this.gameObject);
    }