• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by theredace · Apr 07, 2014 at 11:43 PM · audio sourcedisabled

Audio Source somehow becomes disabled

I have a script attached to a prefab that, in a function, calls an audio clip using:

audio.PlayOneShot (clip);

The audio clip is referenced in the public field in the inspector. I've done this many times before and never had any issue with it. But for some reason, when the function runs, I get no audio and a warning in the console that says "Can not play a disabled audio source". The audio source is enabled and there is no other code anywhere in the script that could possibly be disabling it.

Interestingly, if I try to play it from the start method it works fine. But if I move it anywhere else in the script after the start method, no matter where, it doesn't work and I get this warning message.

I also have another nearly identical prefab in the scene playing audio in the exact same fashion, and it works fine.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image andrew_196 · Apr 07, 2014 at 11:48 PM 0
Share

can I ask whether you have initiated in Start() or Awake() if you have enabled the audio

avatar image andrew_196 · Apr 07, 2014 at 11:53 PM 0
Share

and I was wondering what the warning message says?

avatar image theredace · Apr 08, 2014 at 12:29 AM 0
Share

I haven't enabled the audio in Start() or Awake()... never had to do that before.

The exact warning message says:

Can not play a disabled audio source

UnityEngine.AudioSource:PlayOneShot(Clip)

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by andrew_196 · Apr 08, 2014 at 12:29 AM

Glad I could help gabe, was wondering if I could get the correct answer for anyone else it was a problem with the audio source and clip which was fixed with:

 [RequireComponent(typeof(AudioSource))]

and

 AudioSource.PlayClipAtPoint(winnerClip, new Vector2(0, 0));
Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image theredace · Apr 08, 2014 at 12:38 AM 0
Share

I don't think the audio listener is getting paused anywhere, because I have other sound effects (from other scripts) that will continue playing correctly even AFTER I get this warning message.

I tried unpausing the audio listener as you suggested in the start method and even in my function right before playing the audio clip, but neither worked.

avatar image andrew_196 · Apr 08, 2014 at 12:43 AM 0
Share

sorry to hear that the last thing I can think of is reassigning the audio to the gameobject because if it is a duplicate of a different peice of audio it should be working so try:

copy audio component by clicking on the gear next to the audio symbol and click "copy component" then remove it the same way and then click any of the other gears and paste it. or just go from scratch which is easier if it is simple.

avatar image andrew_196 · Apr 08, 2014 at 12:50 AM 0
Share

one last thing if nowone else can figure this out you could put either the upause or enable in the update which will make sure it is enabled / unpaused all of the time although it is not that efficient

avatar image theredace · Apr 08, 2014 at 01:19 AM 0
Share

Nothing is working. I've tried all your suggestions. I even tried just logging the current enabled state of the AudioSource every frame... and it continues to show that it's enabled before and after the error message saying "Can not play a disabled audio source".

No idea...

avatar image andrew_196 · Apr 08, 2014 at 01:24 AM 0
Share

im sorry to hear that I have tried all of the problems I know this could be a problem with unity itself. because I know for a fact that issue should not be happening. if you want me to take a further look at it you can send the file scene in zip format to my email @:

andrew-j-collins@hotmail.co.uk

or if you have a dropbox?

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Destroying object without interrupting audio source? 2 Answers

How do i get the player to do a delay jump when it collides with a object? 2 Answers

How can i stop my game from laging during instantiation? C# 2 Answers

Destroy GameObject and play sound 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges