mirror of
https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
synced 2025-06-10 22:20:40 +02:00
feat: music volume (#52)
This commit is contained in:
@ -16,6 +16,16 @@ public class LevelLoader : MonoBehaviour
|
||||
private void LoadAudio()
|
||||
{
|
||||
audioSource.clip = Resources.Load<AudioClip>(Path.Combine("Musics", levelsLoader.levelCurrent.musicName));
|
||||
|
||||
if (PlayerPrefs.HasKey("Volume"))
|
||||
{
|
||||
audioSource.volume = PlayerPrefs.GetFloat("Volume");
|
||||
}
|
||||
else
|
||||
{
|
||||
audioSource.volume = 1f;
|
||||
}
|
||||
|
||||
audioSource.Play();
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,33 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PauseMenu : MonoBehaviour
|
||||
{
|
||||
public GameObject pauseMenu;
|
||||
public GameObject pauseButton;
|
||||
public LevelLoader levelLoader;
|
||||
public Slider volumeSlider;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (PlayerPrefs.HasKey("Volume"))
|
||||
{
|
||||
levelLoader.audioSource.volume = PlayerPrefs.GetFloat("Volume");
|
||||
volumeSlider.value = levelLoader.audioSource.volume;
|
||||
}
|
||||
else
|
||||
{
|
||||
levelLoader.audioSource.volume = 1f;
|
||||
volumeSlider.value = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeVolume()
|
||||
{
|
||||
levelLoader.audioSource.volume = volumeSlider.value;
|
||||
PlayerPrefs.SetFloat("Volume", levelLoader.audioSource.volume);
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
|
Reference in New Issue
Block a user