Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Stop music

DamBossikDamBossik Member

Hi. How to stop music. I'm using same audioManager as Brackeys in this video: https://www.youtube.com/watch?v=6OT43pvUyfY. I want to play different music in scenes.

Comments

  • jtok4jjtok4j Member

    Greetings,

    Using the system from the Brackey's tutorial video, you can make a C# script and add it to the scene, placing this line of code in " void Awake() " area to play the music you want from the Audio Manager Script :

    FindObjectOfType<AudioManager>().Play("NAMEOFYOURSOUNDHERE");


    In order to stop the previous music, you can put in this into a script which is run when the current scene is unloaded:

    FindObjectOfType<AudioManager>().Stop("NAMEOFYOURSOUNDHERE");


    These are the general steps. Please see more specific examples in code here: https://docs.unity3d.com/ScriptReference/AudioSource.Stop.html

    and type in more questions as they arise!

     Keep on Creating! 


    Justin of JustinTime Studios (http://unity3d.expert) 

Sign In or Register to comment.