Scriptum/Assets/Scripts/SaveSoundSettings.cs
2022-05-12 20:15:49 +02:00

33 lines
853 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SaveSoundSettings : MonoBehaviour
{
[SerializeField] private Slider volumeSlider = null;
[SerializeField] private Slider musicSlider = null;
private void Start()
{
LoadValues();
}
public void SaveVolumeButton()
{
float volumeValue = volumeSlider.value;
float musicValue = musicSlider.value;
PlayerPrefs.SetFloat("VolumeValue", volumeValue);
PlayerPrefs.SetFloat("MusicValue", musicValue);
LoadValues();
}
void LoadValues()
{
float volumeValue = PlayerPrefs.GetFloat("VolumeValue");
float musicValue = PlayerPrefs.GetFloat("MusicValue");
volumeSlider.value = volumeValue;
musicSlider.value = musicValue;
}
}