MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

UAudioManager needs events

Open CameronVetter opened this issue 10 years ago • 3 comments

Currently there is no way to know the exact moment a sound completes playing, so there is no way to trigger something else once a sound effect is completed.

UAudioManager could send a custom message when the sound is ended or interrupted.

What I'm imagining might look something like this:

UAudioManager.Instance.PlayEvent("OpenWoodChest", gameObject, "OnChestOpened");

CameronVetter avatar Jul 13 '16 16:07 CameronVetter

This is a good feature idea, and I don't think it will be difficult to do. The only caveat I'd add is that Unity doesn't give us any way to know when a sound has actually ended. We currently calculate how long we think the sound will take based on the audio clip length and the pitch (playback speed) when an event is triggered. If the pitch changes while playing, that calculated time will no longer be accurate.

Since it's a bit of an edge case, we may be fine not worrying about it, but if it does become an issue, there's a bit more work for constantly updating the remaining time on an audio clip.

joekellyms avatar Jul 13 '16 23:07 joekellyms

@CameronVetter would you like to do the work to add this functionality?

NeerajW avatar Jul 19 '16 17:07 NeerajW

I'll try to take a look at it, probably won't get to it for a bit, in the middle of a different project right now...

CameronVetter avatar Jul 26 '16 01:07 CameronVetter