Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted Music player little question

Discussion in 'Audio & Video' started by e1e1e1, Jul 29, 2020.

  1. e1e1e1

    e1e1e1

    Joined:
    Jan 11, 2019
    Posts:
    55
    Hey, I want to make music player with more then 2 audio sources.
    how this script line should be for more then 2 audio sources?

    Code (CSharp):
    1.     public void PlayMusic(AudioClip musicClip)
    2.     {
    3.         AudioSource activeSource = (FirstMusicSourceIsPlaying) ? musicSource : musicSource2;
    4.         activeSource.clip = musicClip;
    5.         activeSource.volume = 1;
    6.         activeSource.Play();
    7.     }
    8.     public void PlayMusicWhiteFade(AudioClip newClip, float transitionTime = 1.0f)
    9.     {
    10.         AudioSource activeSource = (FirstMusicSourceIsPlaying) ? musicSource : musicSource2;
    11.         StartCoroutine(UpdateMusicWithFade(activeSource, newClip, transitionTime));
     
unityunity