Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Yehsuah · Apr 26, 2016 at 04:28 PM · buttonaudioaudiosource

UI Button Sounds Volume Increases when Mouse passes over

Like the title says. I have a MainMenu with UI buttons and sound effects, well, the effects sound and work just fine, but when I move my mouse over the buttons, the volume increases each time I enter a new button. Any Idea what this could be? I have 2 AudioSources and 2 Audio clips that are set in script to play certain sounds when you hover/click. Heres a piece of my Buttons script( controls button presses and audio for buttons):

     public AudioSource hoverSource;
     public AudioSource clickSource;
     public AudioClip hoverClip;
     public AudioClip clickClip;
 
     public void onMouseEnter()
     {
         hoverSource.clip = hoverClip;
         hoverSource.Play();
     }
 
     IEnumerator playGame(int SceneNumber)
     {
         clickSource.clip = clickClip;
         clickSource.Play();
         yield return new WaitForSeconds(clickSource.clip.length);
         SceneManager.LoadScene(SceneNumber);
     }
 
     public void Play(int SceneNumber)
     {
         StartCoroutine(playGame(SceneNumber));
     }
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Pharaoh_ · Apr 26, 2016 at 06:48 PM

First of all, there should be one AudioSource on your UI. After all, the current system operates on Hover and Click. Two buttons cannot be hovered or clicked on at the same time (unless you have more than one inputs). Additionally, a click sound should replace a hover sound if it is still playing. Thus, simply attach one AudioSource to your Camera and play the respective sound. The sound source should have 2D spatial blend, given that it's UI. On a side note, having two methods taking the same parameter within the same class is overly redundant. You could use either a global variable for that (shouldn't matter, since you're loading a new scene) or pass the parameter to only one of these.

From your current code, I see no volume changes, so I suspect that multiple buttons play the same sound, which gives the illusion of high volume. This could be something going on in the part of the code you did not post or the OnMouseEnter() is called from multiple buttons simultaneously (in the case they overlap). Use Debug.Log and report the name of the button and hover to only one. If multiple names are reported, then you've got your answer. My recommendation is to fix the single audio source for the time being and then provide further details.

P.S. I am surprised how onMouseEnter() is called. I could have sworn that it is case-sensitive and should be OnMouseEnter().

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Delayed Button Sounds 0 Answers

How to instantly play an AudioSource 0 Answers

how to stop an audio source from playing multiple times; change button text 0 Answers

Audio is always playing 0 Answers

The same audio plays differently on a variety of buttons, how can I change this? 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