I am working on a game right now that needs two sounds to be played (not simultaneously). I made 2 vars, one for each clip, but whenever I try to change between the clips, all audio stops. Here is the code for the variables and changing the clip (if I look in Inspector, it says that the clips did change, but I can’t hear anything):
var Clip1: AudioClip;
var Clip2: AudioClip;
audio.clip = Clip1;
I have the “Play on Awake” button checked off. I am changing the clips in a RepeatButton; I am not sure if that is affecting it…
What he means is that an iPod/iPhone is only capable of decoding one compressed audio stream at a time. You can set things to be uncompressed on import by right clicking on them and selecting ‘Import Options’…
However, the method you’re using (where you change the clip that’s being played, then trigger a play) means that you’re actually triggering a stop aswell.
Hence my ‘PlayOneShot’ suggestion. If you require two sounds to play ‘nearly’ at the same time, you’re better off using the play one shot, or, alternatively, just using two audio sources.
What he means is that an iPod/iPhone is only capable of decoding one compressed audio stream at a time. You can set things to be uncompressed on import by right clicking on them and selecting 'Import Options'...
from what I’ve unerstood, you have a single audio source component attached to a gameObject. Then via code you change the audioClip of this audio source. If this is the case, after changing audioClip you also have to tell unity audio.Play(); as changing audioClip will stop the audio.
so whichever function set’s the new audioClip should do the following :