void Start() { try { soundData data = saveSystem.LoadSoundPref(); music = data.music; }catch (Exception e) { music = true; } if (music) { StartCoroutine(AudioController.FadeIn(GetComponent <AudioSource>(), 1f)); } showSettings = false; //soundEnabled = true; //musicEnabled = true; StartCoroutine(startSunlightAnimation()); LoadData(); LoadPLayerData(); //save both information playerObject.GetComponent <SpriteRenderer>().sprite = GameAssets.i.GetCharacterSprite(index); playerObject.GetComponent <Animator>().runtimeAnimatorController = GameAssets.i.controllers[index]; }
// ------------------------------------------------------------- // public static void SaveSoundPref(bool music, bool sound) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/mus.nfo"; FileStream stream = new FileStream(path, FileMode.Create); soundData data = new soundData(music, sound); formatter.Serialize(stream, data); stream.Close(); }
public static soundData LoadSoundPref() { string path = Application.persistentDataPath + "/mus.nfo"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); soundData data = formatter.Deserialize(stream) as soundData; stream.Close(); return(data); } else { throw new Exception("Save file not found in " + path); } }
private void Awake() { try { soundData data = saveSystem.LoadSoundPref(); music = data.music; } catch (System.Exception e) { music = true; } LoadGameData(); if (music) { StartCoroutine(AudioController.FadeIn(GetComponent <AudioSource>(), 1f)); } }
private void Awake() { try { soundData data = saveSystem.LoadSoundPref(); soundEnabled = data.sound; }catch (Exception e) { soundEnabled = true; } foreach (Sound s in sounds) { s.source = gameObject.AddComponent <AudioSource>(); s.source.clip = s.clip; s.source.volume = s.volume; s.source.pitch = s.pitch; s.source.mute = !soundEnabled; } }
private void Awake() { try { soundData data = saveSystem.LoadSoundPref(); musicEnabled = data.music; soundEnabled = data.sound; } catch (Exception e) { musicEnabled = true; soundEnabled = true; } if (!musicEnabled) { musicIcon.GetComponent <Image>().color = new Color32(168, 117, 68, 255); } if (!soundEnabled) { soundIcon.GetComponent <Image>().color = new Color32(168, 117, 68, 255); } }