x


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!

more ▼

asked Mar 28 '12 at 04:11 AM

DoubleElite gravatar image

DoubleElite
0 2 2 4

How about not playing a disabled audio source? Just enable it.

Mar 28 '12 at 05:34 AM Eric5h5

I went ahead and tried that, no luck. I used "reloadSound.enabled = true;" and reload sound being the AudioSource variable.

Mar 28 '12 at 04:21 PM DoubleElite

Do you have to use an audio source? Try using an audio clip?

Mar 28 '12 at 04:45 PM BHS

Sorry for being late to respond, yes I need to use an Audiosource.

Apr 04 '12 at 02:45 AM DoubleElite
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Apr 30 '12 at 09:02 PM

Bampf gravatar image

Bampf
5.1k 8 20 49

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)

Apr 30 '12 at 10:29 PM Fabkins
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2030
x1060
x563
x20

asked: Mar 28 '12 at 04:11 AM

Seen: 2658 times

Last Updated: Apr 30 '12 at 10:29 PM