- Home /
start function when music stops
hi i was wandering if there is a way to start a function when an audio clip stops playing?
rather than just checking for the audio to stop it must be a function which only starts when the audio has stopped
if not i was thinking i could update the script every second as your not really going to notice a second or two when music is changing
actually further thinking about it, my script is only enabled when the music player is enabled or rather instantiated. so i suppose i could use OnEnabled to start the process and yield between each one until the audio is finished
yh might be the easiest to do, shouldn't really effect my gameplay if its only checking one if statement. may receive a little lag on audio change. but these are stored in an array so hopefully wont be noticeable.
Answer by Unityprogramer10 · Aug 28, 2012 at 12:50 AM
private bool playing = false;
//put this in the update fuction
if(playing)
if(!audio.isplaying){
playing = false;
//start function
}
hope this helps
not really an answer to my question, I'm looking for a way to start a function based on isplaying rather than just using it in an update, which is very expensive on mobile platforms.
i will re edit my question as its a bit misleading
Your answer
Follow this Question
Related Questions
How to check if an object is playing ANY animation 1 Answer
Audio is always playing 0 Answers
Animation Finished 1 Answer
AudioSource.IsPlaying returns true when only playing one shot? 0 Answers
IsPlaying vs isplaying 1 Answer