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 Abacab · Feb 19, 2015 at 08:53 AM · c#menumusicsingleton

How to stop menu music when loading level (1,2,3,..,x)

Hello!

I managed to find a way to have a menu song that doesn't start over between different menu scenes, but I'd like it to stop when I load a playable level. The menu music just seems to turn to a REALLY low volume, but it is still audible.

These two scripts are taking care of the menu music. Could you please find a solution for me?

 public class MyUnitySingleton : MonoBehaviour {
     
     private static MyUnitySingleton instance = null;
 
     public static MyUnitySingleton Instance {
         get { return instance; }
     }
 
     void Awake() {
         if (instance != null && instance != this) {
             Destroy(this.gameObject);
             return;
         } else {
             instance = this;
         }
         DontDestroyOnLoad(this.gameObject);
     }
 }

.

 public class MusicManager : MonoBehaviour {
 
     public AudioClip NewMusic; //Pick an audio track to play.
     public GameObject go;
     
     void Awake () { 
         go = GameObject.Find("Game Music"); 
         //Finds the game object called Game Music, if it goes by a different name, change this. go.audio.clip = NewMusic; 
         //Replaces the old audio with the new one set in the inspector. go.audio.Play(); 
         //Plays the audio. 
     }
 }
Comment
Add comment · Show 5
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 Nymisu · Feb 19, 2015 at 09:23 AM 0
Share

Why are you finding the gameobject with the game music on awake ins$$anonymous$$d of directly affiliating it with the script through the editor?

Also, if it goes quiet, make sure the music being played has "3D sound" disabled. This means that the music will be played at constant volume regardless of its distance to the audio listener.

avatar image Abacab · Feb 19, 2015 at 09:34 AM 0
Share

I created a "$$anonymous$$enu $$anonymous$$usic" gameObject in each scene that I want the music to be played. Should I do it the other way?

alt text

screen-shot-2015-02-19-at-112902.png (43.7 kB)
avatar image kbaloch · Feb 19, 2015 at 12:00 PM 0
Share

you should stop your audio in gameplay scene script

avatar image Abacab · Feb 19, 2015 at 12:34 PM 0
Share

What would be the code?

avatar image AlucardJay · Feb 20, 2015 at 12:55 PM 0
Share

http://answers.unity3d.com/questions/413203/continuous-music-across-multiple-scenes.html

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by alok-kr-029 · Feb 19, 2015 at 12:39 PM

try this AudioSource Audio1 = GameObject.Find("YourgameObject name ").getComponent().Stop();

Comment
Add comment · Show 2 · 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 Abacab · Feb 19, 2015 at 04:29 PM 0
Share

It still keeps playing at a low volume.

avatar image alok-kr-029 · Feb 20, 2015 at 05:02 AM 0
Share
 AudioSource Audio1 = GameObject.Find ("YourgameObject name ").GetComponent<AudioSource> ().volume = 0;

or

 AudioSource Audio1 = GameObject.Find ("YourgameObject name ").GetComponent <AudioSource>.Stop() ;

Try this

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

24 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 avatar image

Related Questions

Play again music problem. (Please help) :) 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Pause Menu Not Pausing 3 Answers

Shouldn't Singletons not extend Monobehaviour ? 4 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