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 $$anonymous$$ · Apr 10, 2018 at 01:15 PM · audioplayerprefssave

How to save an Audio Mixer's value wich is adjusted with a Slider?

Hi Guys! I'm new to Unity and I couldn't figure it out how to save the value of an Audio Mixer properly.

I have 3 scenes in my game: Start menu, Main menu, Gameplay scene;

I have 3 Audio Mixers and 3 Sliders to adjust the main music, the sfx and the button click sound.

Each mixer is attached to its slider via script using its exposed parameter and it works correctly.

My sliders are in my main menu scene's audio window and i tried to put a saving with playerprefs script on my sliders but it only worked partially.

Because when i start the game i have to go into the audio window to get( "Hear" )the changed audio volume which i have adjusted when I started the game previously.

Otherwise my adjustments stays ignored.

Please help me make my adjustments take effect at the start of my game. I really appreciate any help.:) Thx Adam Gombos

alt textalt text

question-2.jpg (373.1 kB)
question-3.jpg (193.8 kB)
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
Best Answer

Answer by poisoned_banana · Apr 10, 2018 at 02:28 PM

For simple values like this use PlayerPrefs. Also I would advise you to create a VolumeManager which exists throughout your whole game. So you can change the volume at any time. For example:

 public class AudioManager : MonoBehavior{
 
    [SerializeField]
    private AudioMixer audioMixer;
 
    public static AudioManager instance;
 
    void Awake(){
       if(AudioManager.instance == null){
          DontDestroyOnLoad(gameObject);
          AudioManager.instance = this;
        }
       else
          Destroy(gameObject);
    }
    void Start(){
         //Get the saved music volume, standard = 10f
        float music = PlayerPrefs.GetFloat("Music",10f);
 
         //Set the music volume to the saved volume
        AdjustMusicVolume(music);
    }
 
    public void AdjustMusicVolume(float volume){
        //Update AudioMixer
       audioMixer.SetFloat("Music",volume);

       //Update PlayerPrefs "Music"
       PlayerPrefs.SetFloat("Music",volume);

       //Save changes
       PlayerPrefs.Save();
    }
 
 }

Put this script on a new GameObject in your MainMenu Scene and you can change the volume from anywhere with AudioManager.instance.AdjustMusicVolume(0.3f)

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 $$anonymous$$ · May 01, 2018 at 01:18 PM 0
Share

Thank you for your answer. :)

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

99 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

Related Questions

Highscore won't save 3 Answers

Save game support, how do I load audio in a sertain time frame? 0 Answers

Instantiate a prefab just one time 1 Answer

Where do I put PlayerPrefs.SetInt? 1 Answer

PlayerPrefs.DeleteAll() not deleting unless app restarts 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