Vergil
July 17, 2013, 11:44am
1
Hi
I have two tracks of music(an intro track and a loop track),i need and a script that plays the Intro track once(as the game starts) and following it(exactly after it’s ending) I want the loop track to begin and fell in loop.
Can anybody help me with that?
Any helps would be appreciated!
here you go this is 1 way
AudioSource MpPlayer;
AudioClip FirstClip;
AudioClip SecondClip;
// Use this for initialization
void Start () {
MpPlayer.clip = FirstClip;
MpPlayer.loop = false;
MpPlayer.Play();
StartCoroutine(WaitForTrackTOend());
}
IEnumerator WaitForTrackTOend()
{
while (MpPlayer.isPlaying)
{
yield return new WaitForSeconds(0.01f);
}
MpPlayer.clip = FirstClip;
MpPlayer.loop = true ;
MpPlayer.Play();
}
edit shit should work now i forgot to call the second function
please follow link bellow and download asset.
-best example for music player(almost everything included)
Discover the best assets for game making. Choose from our massive catalog of 2D, 3D models, SDKs, templates, and tools to speed up your game development process.
Don’t forget to leave your review