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 Toy · Jul 25, 2012 at 03:00 PM · soundsong

Playing the same song on different scenes

Hi there,

I have a simple question,

In my game, I have a scene to choose map, a scene to look at the score, a scene for the credit and so on. I would like to loop a song ( ok for this ) for those scene ( the same song for each scene ). The thing is everytime I change scene, the song restarts.

How can I make this song play whatever of those scene im in ?

Comment
Add comment · Show 1
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 AlucardJay · Jul 25, 2012 at 03:13 PM 1
Share

You'll need to use DontDestroyOnLoad :

http://docs.unity3d.com/Documentation/ScriptReference/Object.DontDestroyOnLoad.html

however, if you do this at the main menu, then from the end of the game co$$anonymous$$g back to the main menu, a new player will be created, so you have to check that if there is an object already existing (because of DontDestroyOnLoad), then destroy itself. Did that make sense? Because the object is not destroyed, every time you enter the scene that has the object, another will be created, but you only want one in existance. (That wasn't much better, was it :S )

I'll look into making a script for this, unless one of the pro's submits an answer for you =]

  • when I did this, I found using a Singleton helped in making sure only one 'music player' was in existance.

  • actually, the first link on Seth's answer is probably the best example using a singleton method (upvote for you sir) =]

http://answers.unity3d.com/questions/11314/audio-or-music-to-continue-playing-between-scene-c.html

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Seth-Bergman · Jul 25, 2012 at 03:06 PM

http://answers.unity3d.com/questions/11314/audio-or-music-to-continue-playing-between-scene-c.html

http://answers.unity3d.com/questions/59135/playing-music-while-scenes-change.html

http://answers.unity3d.com/questions/11671/play-music-through-multiple-scenes.html

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 Toy · Jul 25, 2012 at 03:21 PM

Yes the singleton would be the best thing to use I think

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

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

8 People are following this question.

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

Related Questions

How to know the time of the song? 1 Answer

Music does not play between scenes 2 Answers

The simple way to put sounds in a game? 1 Answer

Can not play a disabled audio source persistent problem 0 Answers

ReverbZone affects 2D sounds 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