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 Dalsia · May 08, 2018 at 07:57 AM · uibuttonaudioload scene

How to prevent button audio from playing on scene load?

I have UI buttons that make noises when selected. Everything works as intended, but when I load my scene the button selection noise plays because the event system selects a default button, even when the user hasn’t tried selecting anything yet. Is there a way to prevent this? As far as I’m aware you need to assign a default button to the event system or none of your buttons will work. Also, is there a way to stop the mouse cursor from triggering these sounds? I’ve scripted away the ability for the mouse to trigger any button functionality, but it still makes the button selection sounds when clicked.

Comment
Add comment · Show 1
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 Pinkuboxu · May 08, 2018 at 02:06 PM 1
Share

Are you following someone else's implementation? I ask that because it sounds like you don't actually know how it's making the sound. I would have to take a look at your implementation to know what is wrong.


I do know that you do not need to set up a default button for buttons to work, this also makes me think you are using another party's implementation. Buttons don't make sounds unless you code them to do so or set it up in their OnClick event in the inspector. If you can supply some code and screen shots I can help.


I usually just set up my buttons to have two OnClick events in the inspector. One for the sound by accessing an AudioSource and it's PlayOneShot() method and giving it a sound clip... then the other OnClick Event Points to the script that has a public void method that does whatever I want the button to do when it is pressed. Like I said, I don't know what you are doing yet so I can't help until I see it. But I would suggest understanding exactly the system you are using or you are going to be frustrated all the time.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by tormentoarmagedoom · May 08, 2018 at 08:24 AM

Good day.

First, Where the Audiosource are? is one for all butons? or every button ahve a AudioSource?

I'm not 100% sure, but i think this is false : "you need to assign a default button to the event system or none of your buttons will work".

Anyway, you can modify the volume for example

 AudioSource.volume = 0 ;

And activate it at the first Update frame (once everything has been initialized)

OTher thing is, did you check your audiosource? is the "Play on awake" activated? if it is... this is the problem!

Give feedback! Bye!

Comment
Add comment · Show 4 · 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 Dalsia · May 08, 2018 at 08:46 AM 0
Share

I have an “Audio$$anonymous$$anager” as my audio source, but each button has an event trigger attached to it that plays a sound when selected. Play On Awake is not selected.

avatar image tormentoarmagedoom Dalsia · May 08, 2018 at 10:17 AM 0
Share

Then if you have an audiomanager, just make the volume to be 0 at the start, and crea$$anonymous$$ if sentence iside update with

 bool InitialVolumeSet = false;

 void Update()
 {
  if (InitialVolumeSet == false && Input.any$$anonymous$$ey)
  {
   Change volume to normal value
   InitialVolumeSet = true
  }
 }

OR something like this!

So you will prevent this initially sound!

Bye :D

avatar image Pinkuboxu · May 08, 2018 at 01:21 PM 0
Share

I'm pretty sure, as well, that you do not need a default.

avatar image LilGames · May 08, 2018 at 02:33 PM 1
Share

You are proposing a band-aid fix. The developer needs to post code and describe the actual set-up. As you pointed out, it doesn't seem like they set things up correctly.

avatar image
0

Answer by Dalsia · May 08, 2018 at 05:10 PM

I appreciate most of your responses, but the answer was a lot simpler than we all thought. Instead of making my buttons play a noise when "selected," I had to make them play a noise when deselected using Unity's event trigger component. The UI selection sound no longer plays when starting a scene.

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

161 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 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 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 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 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 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 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

How to access the OnClick event via Script 1 Answer

Animator has not been initialized?? 3 Answers

Get UI Button dimensions in game via script C# 1 Answer

Holding down UI Button and shooting raycast from touch position doesn't work simultaneously:(( 0 Answers

Destory button on click and other problem 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