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 knuckles209cp · Dec 28, 2013 at 08:14 AM · soundslidervolumehorizontal

Change sound dependent on slider?

So i have a options button , and when you press you have the option to change sound volume , i have made the slider and everything but i dont know how to change all sound according to it , ad by the sounds of it its REALLY complex and i need the best help i can get . please dont be harsh as i am new to java ( i have only been doing it for about half a year )

 var Msensitivity : float = 5;// dont worry about this
 var Volume: float = 5;
     
     function OnGUI () {    
            
         Msensitivity = GUI.HorizontalSlider (Rect (800, 175, 400, 25), Msensitivity, 0.0, 10);//dont worry about this
         Volume = GUI.HorizontalSlider (Rect (800, 250, 400, 25), Volume, 0.0, 10);
         }
         
 
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 Josh707 · Dec 28, 2013 at 08:41 AM 0
Share

I think you could save a 0.0 to 1.0 value for master volume in PlayerPrefs - Any audio sources could get the master volume and set it before playing

avatar image knuckles209cp · Dec 28, 2013 at 08:56 AM 0
Share

ok , then how do i make it so when i change the slider the volume changes aswell?

1 Reply

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

Answer by Pitomator · Dec 28, 2013 at 01:17 PM

First you are using JavaScript (or UnityScript) and not Java ;)

Try this after you Vulume = ... line:

 AudioListener.volume = Volume;

Hope it helps

Comment
Add comment · Show 5 · 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 knuckles209cp · Dec 29, 2013 at 01:28 AM 0
Share

I will try that :) thank you

avatar image knuckles209cp · Dec 29, 2013 at 01:31 AM 0
Share

it works!!!!!!!!! , but one problem , i have 3 scenes in my game and it lowers the volume for one scene only

avatar image Pitomator · Dec 29, 2013 at 10:30 AM 1
Share

It is most likely because you store the volume in a local variable and you have the script in all your scenes. Either store it in a static variable or only have the volume adjustment script in one scene, hope it helps :) Static variables look like this:

static var volume : float = 0;

avatar image knuckles209cp · Dec 31, 2013 at 01:50 AM 0
Share

Thank you ! It works perfect! thumbs up :D

avatar image knuckles209cp · Dec 31, 2013 at 01:51 AM 0
Share

oh , how would i make it for all sound , i only did a audio source

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

20 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

Related Questions

Controlling Master Volume with one slider? 1 Answer

Link Horizontal Sliders? 0 Answers

how to change and save audio volume from a different scene with a slider 1 Answer

Far- heard sound using Detonator 2 Answers

The volume does not reduce when master volume is lowered using volume slider 3 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