Example #1
0
    // Use this for initialization
    void Start()
    {
        if (musicAlreadyExist)
        {
            Destroy(gameObject);
        }
        else
        {
            musicAlreadyExist = true;
            AudioSource.DontDestroyOnLoad(gameObject);

            Music = this.GetComponent <AudioSource>();
            GameObject.DontDestroyOnLoad(Music);

            Music.Play();
            Music.clip = Game;
            Music.loop = true;
        }
    }