Ejemplo n.º 1
0
    public static void Crossfade(AudioClip newTrack)
    {
        Instance.StopAllCoroutines();

        if (Instance.GetComponents <AudioSource>().Length > 1)
        {
            Destroy(Instance.GetComponent <AudioSource>());
        }

        AudioSource newAudioSource = Instance.gameObject.AddComponent <AudioSource>();

        newAudioSource.volume = 0.0f;

        newAudioSource.clip = newTrack;

        newAudioSource.Play();

        Instance.StartCoroutine(Instance.ActuallyCrossfade(newAudioSource, 1.0f));
    }