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 entity476 · Apr 06, 2013 at 03:39 PM · audiovolumelistener

Is it possible to change Audio Manager Volume by script?

Hi!

It happens that I have two audio Listeners in my scene (with one enabled when the other is disabled). I found out that no matter which Listener is enabled, if I would change the value in Audio Manager Settings (project settings, it will affect the overall volume. Well, is it possible to change that by script?

I know that I could achieve the same result by getting all the listener components (or the one currently enabled) and change their volume value. But except of that would be slightly more complicated, isn't it more efficient to approach it from the shortcut way I look for?

Thank you!

Comment
Add comment · Show 2
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 entity476 · Apr 06, 2013 at 01:42 PM 0
Share

I was afterwards looking to what is called singleton pattern. I guess, it would be useful to understand the concept and it seems that it would do the job. But is there a quicker solution however?

avatar image entity476 · Apr 06, 2013 at 01:57 PM 0
Share

Thinking back, I will just try to affect Object1.AudioListener.volume and Object2.AudioListener.volume from the script which controls when the overall, lets call it master, volume has to change. Probably I shouldn't post before I try some workarounds. But except of that I was looking for a quick, yes/no, answer, this last idea of $$anonymous$$e wouldn't be feasible for a big number of objects with audio listeners or if it was not known which instances would have audio listeners, I guess.

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by SrBilyon · Apr 06, 2013 at 08:42 PM

I'm not sure why you have two audio listeners.

Anyway, you could use AudioListener.volume to control the volume of the game (assuming one audio listener is used).

Or (untested), you would get all the audio listeners, loop through them, and modify the AudioListener.volume for each.

Comment
Add comment · Show 1 · 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 entity476 · Apr 06, 2013 at 09:56 PM 0
Share

Thank you SirVictory for opening my eyes (or my ears in this case)!

First, the reason I used two audio Listeners, is just because of the simplest trick that came first on my $$anonymous$$d, when I wanted to use some different behavior of sound when I'm into pause mode. Although I cannot recall at the moment the details that made me to decide (and probably it was an unnecessary decision) towards this solution, however what I can now tell is that I used 1 audio listener too far away from the actual scene, in order to activate it when I pause the game. in other words, when I press pause, what I probably tried, was to not mess with taking care of how to mute the 3D audio clips, which are playing during the action. Ins$$anonymous$$d, I let them play and I used a non-3D audio clip, which is able to be listened only from that distant audio listener, as a background music. As I said, it might have been an unorthodox way.

About your second suggestion, I agree, that this was the first idea which came on my $$anonymous$$d, but I was wondering, if there is a direct way to change, by script, the Volume in Project Settings -> Audio, at the same fashion you can do with the default speaker mode for example.

With your first suggestion though, I realized how silly I am, for thinking that a component with this class has to be attached on every object with an audio listener and by being prejudiced from that, I didn't even read the script reference! Also, for some dark reason, while I was searching for "master volume" keywords and so on, I hadn't come across to the existing answer here.

By the way, what I noticed finally is that AudioListener.volume overrides the Audio manager settings. If the first is 1.0 and the latter 0.0, the audio will be listened. And since the post started with the volume in Audio $$anonymous$$anager, I see it takes values higher than 1 (also negative ones). Well, as I said, it takes no effect when a AudioListener.volume class comes in play, but, otherwise, it only affects the sound for values between 0 and 1. Why then the field 'Volume' accepts these other values? Is it just a little neglect? Finally any connection with the Audio $$anonymous$$anager volume parameter and the AudioListener.volume?

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

11 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

Related Questions

Audio Sources and Listeners low sound volume problem 1 Answer

Set volume problems 1 Answer

Separate Listeners for Sound FX and Music? 0 Answers

Volume rolloff: Distance to listener not changing. 3 Answers

Is it possible to raise an audio sources pitch as an audio listener gets closer? 5 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