- Home /
Warning: "Can not play a disabled audio source"
Hello everyone! I recently got Unity 3.5 and I'm having an error everytime I try to play an AudioSource. The sound is a 2D sound and is in a prefab. Upon activating the sound I get the error(warning); "Can not play a disabled audio source". However the sound still plays perfectly. Any ideas? Can I disable the warning? EDIT: Here's the snip'it of code with the audio
if(!reloading && Input.GetButtonDown("Reload") && currentClip < clipSize && currentExtraAmmo > 0) {
reloading = true;
gunAnimation.CrossFade("reload");
reloadSound.Play();
}
if(!reloading && Input.GetButtonDown("Fire1") && currentClip == 0 && currentExtraAmmo > 0) {
reloading = true;
gunAnimation.CrossFade("reload");
reloadSound.Play();
}
Thanks!
How about not playing a disabled audio source? Just enable it.
I went ahead and tried that, no luck. I used "reloadSound.enabled = true;" and reload sound being the AudioSource variable.
Sorry for being late to respond, yes I need to use an Audiosource.
Answer by Bampf · Apr 30, 2012 at 09:02 PM
Try adding calls to Debug.Log next to the code that a) plays the sound, and b) enables the audio source. Maybe they aren't occurring in the order you think they are.
An interesting other issue is when you destroy the object. ie have an object that makes a sound when destroyed but if you destroy the object the sound doesnt play. ( I know it sounds obvious but not so when see the code)