Created
November 24, 2017 20:53
-
-
Save anonymous/d6d849c16a44c10bd128d57e0a560683 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
using System.Collections; | |
public class OptionsController : MonoBehaviour { | |
public Slider volumeSlider; | |
public Slider difficultySlider; | |
public Slider survivalSlider; | |
public LevelManager levelManager; | |
private MusicManager musicManager; | |
// Use this for initialization | |
void Start () { | |
musicManager = GameObject.FindObjectOfType<MusicManager> (); | |
volumeSlider.value = PlayPrefsManager.GetMasterVolume(); | |
difficultySlider.value = PlayPrefsManager.GetDifficulty (); | |
survivalSlider.value = PlayPrefsManager.GetSurvivalMode (); | |
} | |
// Update is called once per frame | |
void Update () { | |
musicManager.ChangeVolume (volumeSlider.value); | |
} | |
public void ApplyAndExit (){ | |
// saving the volume and difficulty to the PlayerPrefs | |
PlayPrefsManager.SetMasterVolume (volumeSlider.value); | |
PlayPrefsManager.SetDifficulty (difficultySlider.value); | |
PlayPrefsManager.SetSurvivalMode (survivalSlider.value); | |
levelManager.LoadLevel ("01a Start"); | |
} | |
public void SetDefaults(){ | |
volumeSlider.value = 0.5f; | |
difficultySlider.value = 2f; | |
survivalSlider.value = 0f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment