How to save Slider fill area in Xml?
I have been trying for days to make a saving system that can save the player settings. My only problem is that when a player has tweaked the sound settings and reopen the game. Then the game will load the saved volume, but the Slider will be reset. So My problem is How can I save the Volume and the slider fill area, and be able to load at the start of the game?
I thought of maybe trying to save these values, except for Pos Z And when starting the game it just has to load these 4 values back in the Slider Fill area. Don't know if it is a good idea, and I don't know if these values are floats or vectors.
My script so far:
public void SaveSettingsData()
{
SaveManagerPlayerPreferences.instance.activeSettingsSave.masterVolume = currentVolumeForMaster;
SaveManagerPlayerPreferences.instance.SavePlayerPreferences(); //Instance Save
}
void Start()
{
if (System.IO.File.Exists(Application.persistentDataPath + "/" + SaveManagerPlayerPreferences.instance.activeSettingsSave.saveName + ".preferencesSave"))
{
newVolumeForMaster = SaveManagerPlayerPreferences.instance.activeSettingsSave.masterVolume;
ChangeMasterVolume(newVolumeForMaster);
}
}
public void ChangeMasterVolume(float newVolume)
{
audioMixer.SetFloat("MasterVolume", Mathf.Log10(newVolume) * 20);
}
Any help will be much appreciated! Thank you for reading this.
Your answer
![](https://koobas.hobune.stream/wayback/20220613024904im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do i add coins in my Save Total Coin, everytime i collect more coins in the game? 0 Answers
Random XML Questions Using Fisher-Yates Shuffle 0 Answers
Save and load player position in main scene 1 Answer
xml file read as MonsterCollection.cs 0 Answers
Help offline progression, works on windows but not on Android. 0 Answers