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 rwdesign · Apr 15, 2014 at 03:37 PM · c#audiosceneapplication.loadlevel

problems with continuous audio between scenes

hello, I am new to programming and I need some help with audio ... I have a series of five scenes, and wanted the music played in scene 1, continue playing without interruption when I go to scene 2, 3, and so on when using Application.LoadLevel ...

could someone help me? I'm doing the scrip in C # ... thank you in ...

Comment
Add comment · Show 2
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 rwdesign · Apr 17, 2014 at 07:20 PM 0
Share

Wow! Perfect guys! Works perfectly! You are very good!

Have one last thing I need to ask: I'm doing an initial menu, and it has the Play, Options and Quit options. By staying transitioning between Play> Options / Options> Play, the music continues to play, but when you click Play, I need it to stop ...

Can anyone help me with this last question?

avatar image DMCH · Apr 17, 2014 at 07:29 PM 0
Share

First you need to get the audiosource. One way to do that is to declare a field to hold the (at top of script)

public AudioSource audioSource;

Then, in start, get the audio source:

audioSource = this.gameObject.GetComponent(); (or you should be able to drag it in)

Now, you will be able to interact with it. To stop the song you need enter this instruction in the play button.

audioSource.Stop();

You may also want to look into fading the volume out, by using audioSource.volume.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DMCH · Apr 15, 2014 at 03:50 PM

In the awake function of the script attached to the audio object, try adding:

DontDestroyOnLoad(gameobject);

This will prevent the object and any attached scripts from being destroyed between scenes. Not sure how it will work with music, as I've never needed to have continuous audio, but it's worth a go. Let us know how it goes.

Comment
Add comment · Show 1 · 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 rwdesign · Apr 16, 2014 at 11:30 PM 0
Share

worked perfectly, but now have another problem ... when I go back to the first scene, the music keeps playing, and at the same time, it starts at the bottom ... ie ...

two songs playing at the same time ...

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

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

Continuous music on selected scenes? 2 Answers

Play Audio Through Scenes 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Unity 5.3 How to load current level 3 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