The question is answered, right answer was accepted
AudioSource.PlayOneShot() is not looping
Good Evening,
I'm having a problem with an AudioSource. On the inspector the AudioSource is set to loop. But if I use PlayOneShot it doesn't loop at all. To fix that I had to load the clip I want to loop in the inspector. But I don't want to have an object with an AudioSource for each AudioClip I need to loop. Is that a bug, or am I missing something?
Thanks in Advance.
Answer by taylank · Jan 08, 2016 at 06:00 AM
PlayOneShot does exactly what the name suggests, it plays the audio clip once and stops. You may instead want to assign the audio clip in the inspector, set it to loop, and then use the Play() function instead. http://docs.unity3d.com/ScriptReference/AudioSource.Play.html
For changing the audio clip, you simply assign a new clip to the AudioSource.clip variable of the AudioSource component (you only need one of that).
Check out the example here: http://docs.unity3d.com/ScriptReference/AudioSource-clip.html
Hi, it works but then I wouldn't be able to set the volume of a single clip (is there any other way to do it without the function "play()"?
Follow this Question
Related Questions
Check if tag is the same as the previous one 1 Answer
Found a weird problem about AudioSource.PlayOneShot 2 Answers
How to load an audiosource on trigger once? 2 Answers
I'm trying to play a sound OnCollisionEnter, but something isn't working right. Can you help me ? 0 Answers
Im trying to turn off a sound when i leave a trigger collider 0 Answers