jump-game/Jump Game/Assets/Scripts/Menu/SettingsMenu.cs

22 lines
563 B
C#
Raw Normal View History

2022-03-30 16:38:03 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
2022-04-01 05:47:42 +00:00
using UnityEngine.UI;
2022-03-30 16:38:03 +00:00
public class SettingsMenu : MonoBehaviour
{
public AudioMixer audioMixer;
2022-04-01 05:47:42 +00:00
public Slider volumeSlider;
2022-03-30 16:38:03 +00:00
2022-04-01 05:47:42 +00:00
void Start(){
volumeSlider.value = PlayerPrefs.GetFloat("volume", -0.30f);
audioMixer.SetFloat("volume", PlayerPrefs.GetFloat("volume", -0.30f));
}
2022-03-30 16:38:03 +00:00
public void setVolume (float volume){
2022-04-01 05:47:42 +00:00
PlayerPrefs.SetFloat("volume", volume);
2022-03-30 16:38:03 +00:00
audioMixer.SetFloat("volume", volume);
}
}