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 Matthew 5 · Jan 28, 2011 at 12:06 AM · scenechange

Music multiple scenes - Bug or really simple error?

Hey everyone,

I have built a game that Has a Main Menu and a Music credit page (accessable fromt Main Menu through GUI button.

I have music on a empty GameObject and in my GUI button script looks like this;

if (GUI.Button (Rect ( Screen.width * 0.75, Screen.height * 0.4, 120, 50), "Music", "button")) {

 DontDestroyOnLoad(GameObject.Find("musicplayer"));
 Application.LoadLevel ("musicpage");

}

So the new page loads fine, the GameObject is there, BUT no music is playing?.... why?

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 Matthew 5 · Jan 28, 2011 at 12:47 AM 0
Share

...i just found now, when i return to the main menu from the $$anonymous$$usic page, the song continues from where it left off?... so why cant i hear it in the music page?

avatar image Matthew 5 · Jan 28, 2011 at 01:00 AM 0
Share

..also i have just realised a fault with my logic.. because i had a dontdestroy on my music music page returning back to the main menu, the song resume there (as per above?) but also a new instance would begin to play.. crap! the singleton maybe be my best option :(

2 Replies

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

Answer by Matthew 5 · Feb 07, 2011 at 03:51 AM

Just to bring closure to this post.. i created a blank scene at the start of my project with AudioSource, AudioListener & DontDestroyOnLoad.

Then in the "Intro/Menu" scene i had a script which check ifaudio is playing, dont destroy, if not, play new instance... then the DestroyObject was in my first level of the game.... worked a treat.

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 Bunny83 · Jan 28, 2011 at 03:42 AM

When your "musicplayer" still exists in your "Music page" i guess you don't have an AudioListener in your scene. The Listener is normally attached to your camera.
You may also take a look at the scripting reference.

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 Matthew 5 · Feb 07, 2011 at 03:52 AM 0
Share

This was exactly the reason why it didnt work AND got me to figured out the rest of the problem. Thank you

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

No one has followed this question yet.

Related Questions

Laggy gameplay and occasional crashes 1 Answer

Scripting a "touch" on an object in iOS. 3 Answers

Is there an OnSceneChange event? Or some kind of event that is triggered when a new scene is loaded? 2 Answers

Player object carried from scene to scene 1 Answer

Move camera upon button press 0 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