void Awake() { var slider = GetComponent <Slider>(); slider.value = Settings.GetFloat(key.Strings(), 1f); slider.onValueChanged.AddListener((value) => { Settings.SetFloat(key.Strings(), value); if (audioClip == null) { return; } if (notifyCoroutine != null) { StopCoroutine(notifyCoroutine); } notifyCoroutine = StartCoroutine(NotifyAudioVolume(value)); }); }
void Awake() { var audioSource = GetComponent <AudioSource>(); audioSource.volume = Settings.GetFloat(key.Strings(), 1); Settings.OnChange.AddListener((key) => { if (key != this.key.Strings()) { return; } audioSource.volume = Settings.GetFloat(key, 1); }); }