Menuing and stuff also sound or smtg but not joever
This commit is contained in:
parent
33467f6cc4
commit
b3a87fb2a6
14 changed files with 6294 additions and 26 deletions
36
Assets/Scripts/SoundSettings.cs
Normal file
36
Assets/Scripts/SoundSettings.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SoundSettings : MonoBehaviour
|
||||
{
|
||||
[HideInInspector] public AudioSource source;
|
||||
public AudioClip clip;
|
||||
public string clipname;
|
||||
public bool isLoop;
|
||||
public bool playOnAwake;
|
||||
|
||||
[SerializeField] Slider slider;
|
||||
[SerializeField] AudioMixer audioMixer;
|
||||
|
||||
public void SetVolume(float value)
|
||||
{
|
||||
if (value < 1)
|
||||
{
|
||||
value = 0.01f;
|
||||
}
|
||||
RefreshSlider(value);
|
||||
PlayerPrefs.SetFloat("Saved Maseter Volume", value);
|
||||
audioMixer.SetFloat("Master Volume", Mathf.Log10(value / 100) * 20f);
|
||||
}
|
||||
|
||||
public void SetVolumeFromSlider()
|
||||
{
|
||||
SetVolume(slider.value);
|
||||
}
|
||||
|
||||
public void RefreshSlider(float value)
|
||||
{
|
||||
slider.value = value;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue