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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by MC HALO · Feb 25, 2011 at 04:32 AM · audiosoundstop

How to stop Audio not all??

Hi guys i would like to ask something, just picture this in your head say you have 3 GUIs on the screen each plays a song. when you click on GUI one the song will start and etc. what i want is if i click on the 3rd GUI button which will say Track 3 i want the first music to stop playing only, i want the 2nd GUI and the 3rd GUI song to keep on playing. I have tried:

   audio.Stop();

Now if i use that it stops all the sounds and plays the one you clicked on, Now is there anyway that i can stop a specific soundtrack only in this case the first one.

i have tried

audio.Stop(Name of the Var in here);

and that brings up a error on in unity

can someone please help me put an end to this problem thanks in advance

:)

here is the script :

var MyAudioTrack1Naruto : AudioClip; var MyAudioTrack2Naruto : AudioClip; var MyAudioTrack3Naruto : AudioClip; var MyAudioTrack4Naruto : AudioClip; var MyAudioTrack5Naruto : AudioClip;

              function OnGUI () { 

                  //Make the first button
                      if(GUI.Button (Rect(10, 20,105,20),  "Play Track 1 (Naruto Enter) ")){
                           if (!audio.isPlaying){
                                     //audio.Stop(); //if something else is playing stop it and then play track 
                                        audio.clip = MyAudioTrack1Naruto;
                                            audio.PlayOneShot(MyAudioTrack1Naruto);  

      }
              }


       if (GUI.Button (Rect(10, 42,105,20),  "Play Track 1 (Naruto Enter) ")){

               audio.PlayOneShot(MyAudioTrack2Naruto);

}

           if (GUI.Button (Rect(10, 64,105,20),  "Play Track 1 (Naruto Enter) ")){
                                     audio.PlayOneShot(MyAudioTrack3Naruto);
                   } 

                     if (GUI.Button (Rect(10, 86,105,20),  "Play Track 1 (Naruto                Enter) ")){

                               audio.PlayOneShot(MyAudioTrack4Naruto);

}

                           if (GUI.Button (Rect(10, 108,105,20),  "Play Track 1 (Naruto Enter) ")){

                                            audio.PlayOneShot(MyAudioTrack5Naruto);

}

                  if (GUI.Button(Rect(10, 128,105,20),  " No track  ")){

 }
   }

Comment
Add comment · Show 3
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 Bunny83 · Feb 25, 2011 at 04:59 AM 0
Share

How many audiosources do you use? How do you play them? where is/are the audio source(s) attached? What so you mean by GUI? A GUITexture? or a True GUI created in OnGUI()? Your question is a bit confusing... So you want to play max. two songs at once and when clicking on another the olderst song stops and the new one starts?

avatar image MC HALO · Feb 25, 2011 at 05:28 AM 0
Share

Im going to upload the Script.

avatar image MC HALO · Feb 25, 2011 at 05:36 AM 0
Share

No what i want to do is if i click on the GUIs i want them to play songs, i know they will over lap but what i am trying to say is if the user hits the track 3 GUI i want the 2nd track to keep playing but the first track will stop. So that means i know have track 2 and 3 playing :)

0 Replies

· Add your reply
  • Sort: 

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

Which sound files does unity support for games? 1 Answer

Sound stops when object is destroyed 6 Answers

A node in a childnode? 1 Answer

Unity disables my Sound Card 1 Answer

Help With GUI Stop and play other Sound ? 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