You can stop a public AudioSource
from playing by calling the Stop()
method on the AudioSource
component.
Here's an example of how you can stop a public AudioSource
called myAudioSource
from being played in a game:
main.cs303 chars16 lines
In your game code, you can call the StopAudio()
method to stop the AudioSource
from playing:
main.cs35 chars2 lines
This will check if the AudioSource
is not null and is currently playing, then it will stop the audio.
gistlibby LogSnag