Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Audio How to keep audio settings the same after each restart ?

Discussion in 'Audio & Video' started by Nekuneku, Aug 15, 2018.

  1. Nekuneku

    Nekuneku

    Joined:
    Mar 27, 2017
    Posts:
    50
    Hello,

    Anybody have an idea how to the keep the audio settings the same after each time a game restarts?
    Every time i launch the game and mute the background music or the sfx it works fine but after a game over or a restart from the player ,the settings goes back to their original state ,which will be very annoying to keep disabling them after each restart.
    I'm using an audio source attached to a game object,it plays on awake, and controlled by GUI toggle button

    Any help in solving this issue will be greatly appreciated
    Thanks for reading and for your time

    Cheers
     
  2. abhuva

    abhuva

    Joined:
    Dec 23, 2011
    Posts:
    76
    Saving the gamestate isnt something that is handled automatically. You have to script a solution yourself - check out playerprefs for example. They provide an easy way to store simple things. You have to read them at start and set the state of your audio source via script.
     
    Nekuneku likes this.