basically the whole game
This commit is contained in:
parent
949135cecb
commit
96dcfa9064
315 changed files with 34386 additions and 396 deletions
41
Assets/Scripts/SettingsMenu.cs
Normal file
41
Assets/Scripts/SettingsMenu.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SettingsMenu : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TextMeshProUGUI sfxLabel;
|
||||
[SerializeField] private Slider sfxSlider;
|
||||
[SerializeField] private TextMeshProUGUI musicLabel;
|
||||
[SerializeField] private Slider musicSlider;
|
||||
[SerializeField] private AudioMixer mainMixer;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (PlayerPrefs.HasKey("SFXVolume"))
|
||||
{
|
||||
sfxSlider.value = PlayerPrefs.GetFloat("SFXVolume");
|
||||
}
|
||||
if (PlayerPrefs.HasKey("MusicVolume"))
|
||||
{
|
||||
musicSlider.value = PlayerPrefs.GetFloat("MusicVolume");
|
||||
}
|
||||
|
||||
UpdateSFX();
|
||||
UpdateMusic();
|
||||
}
|
||||
|
||||
public void UpdateSFX()
|
||||
{
|
||||
sfxLabel.text = $"SFX ({(sfxSlider.value * 100).ToString("F1")}%);";
|
||||
mainMixer.SetFloat("SFXVolume", Mathf.Log10(sfxSlider.value) * 20);
|
||||
PlayerPrefs.SetFloat("SFXVolume", sfxSlider.value);
|
||||
}
|
||||
public void UpdateMusic()
|
||||
{
|
||||
musicLabel.text = $"Music ({(musicSlider.value * 100).ToString("F1")}%);";
|
||||
mainMixer.SetFloat("MusicVolume", Mathf.Log10(musicSlider.value) * 20);
|
||||
PlayerPrefs.SetFloat("MusicVolume", musicSlider.value);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue