Scriptum/Assets/Scripts/SaveSoundSettings.cs

28 lines
592 B
C#
Raw Permalink Normal View History

2022-05-12 20:15:49 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SaveSoundSettings : MonoBehaviour
{
[SerializeField] private Slider volumeSlider = null;
private void Start()
{
LoadValues();
}
public void SaveVolumeButton()
{
float volumeValue = volumeSlider.value;
PlayerPrefs.SetFloat("VolumeValue", volumeValue);
LoadValues();
}
void LoadValues()
{
float volumeValue = PlayerPrefs.GetFloat("VolumeValue");
volumeSlider.value = volumeValue;
}
}