How to make an audioclip stop when button press
Posted: Fri Nov 17, 2023 4:09 pm
Hello everyone, I am brand new to this asset in Unity so I could really use some help that the documentation didn't really help me with. So I have a dialogue that starts with a person snoring. I have a script that starts the snoring and it stops shortly after an alarm plays. The alarm is set to a loop and will continue to play until I select one of two options [Press Snooze] or [Wake up]. The problem is I can't get it to stop at all. I tried looking into Sequences where I found an AudioStop sequence and reference my AlarmStop Method in my c# script but that isn't working. I have it like this AudioStop(SoundManager.AlarmStop); When I select check it shows up green so it looks like it would work. I also found something that said to write it like this [Script(SoundManager.AlarmStop)] but that doesn't work either. Then I read something that said I need to expose my script via Lua. So I added this to my script Lua.RegisterFunction("AlarmStop", this, SymbolExtensions.GetMethodInfo(() => AlarmStop())); and then wrote the sequence like this [Lua(AlarmStop())] and that didn't work either. So I am at a loss and could use some help. How my dialogue is set up is as follows.
1. Snoring audio starts and ZZZZZZZZ shows up in my dialogue the a few seconds later an alarm sounds goes off
2. "Ugh it is morning already" comes up next and I select that to show two options
3. Hit Snooze or Wake up
4. I want both of those to stop the alarm sounds
1. Snoring audio starts and ZZZZZZZZ shows up in my dialogue the a few seconds later an alarm sounds goes off
2. "Ugh it is morning already" comes up next and I select that to show two options
3. Hit Snooze or Wake up
4. I want both of those to stop the alarm sounds