Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by Hoeloe · Apr 28, 2014 at 09:30 PM · audioaudiosourceloadlevelaudiolistener

Audio from new scene begins half way through loading.

Hey,

So, I'm loading in a scene using Application.LoadLevel, and it all works fine, except for one thing. For some reason, the audio from the scene that is currently loading seems to start the moment the audio source has been loaded. This means I get atmospheric sound effects playing during loading. The really odd thing about this is that it seems to totally ignore the AudioListener's state. I have tried both AudioListener.pause and AudioListener.volume = 0, and neither solves the issue (the sound does stop after the scene is loaded, but still plays during the loading period). Is there anything I can do to prevent this from happening?

Comment
Add comment
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

2 Replies

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

Answer by Hoeloe · May 11, 2014 at 11:32 PM

I have fixed this! The issue arose because I was changing AudioListeners between scenes (I had a different camera setup in each scene, and it was easier to remove the camera than to attempt to change the scripts attached to it on loading the scene). This meant that, when I changed the volume of the AudioListener before loading the scene, it set the volume of the existing AudioListener. But, it then swapped that Listener for a new one, that I had no control over. Once I realised this, it was just a case of adding something along the lines of:

 void OnLevelWasLoaded()
 {
      AudioListener.volume = 1;
 }
 
 void Start () 
 {
      AudioListener.volume = 0;
 }

So the volume is set to 0 immediately after the AudioListener is created, and reset again once the level is fully loaded.

Comment
Add comment · 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
0

Answer by monogon · Apr 28, 2014 at 11:53 PM

Uncheck the box "Play on awake" on your AudioSource. Then play the clip from script when the level has loaded.

Comment
Add comment · Show 3 · 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 Hoeloe · Apr 29, 2014 at 08:21 AM 0
Share

That made no difference. Well, almost no difference. It at least pays attention to the AudioListener's volume, to some extent (that is, if, in the new scene, I have the audio volume set to 0, it won't play the sound during loading either). However, it still plays the sound while loading if I don't have the in-game audio volume set to 0.

avatar image monogon · Apr 29, 2014 at 10:44 AM 0
Share

I don't know why your problem occurs or whether it is a common problem but unless someone has a better fix for it you could try this work-around.

 Application.LoadLevel("anyLevel");
 AudioSource.volume = 0f;

Then when the level has loaded:

 OnLevelHasLoaded(int level) {
 
 AudioSource.volume = 1f;
 
 }

It's a work-aroung but not a very nasty or unstable one I think. You might try it.

avatar image Hoeloe · Apr 29, 2014 at 12:09 PM 0
Share

That's exactly what I'm doing already - it doesn't work.

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.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

How do I only start the audio when player is at max distance 1 Answer

Audio not playing well on AudioListener move 1 Answer

Real time audio source on audio listener.... 0 Answers

Audio: -3db automatic attenuation on any audio playing? 0 Answers

GetSpectrumData or equivalent in non-realtime mode? 2 Answers


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