using UnityEngine; using UnityEngine.UI; public class PlayerAmbientSound : MonoBehaviour { public AudioSource ambientSource; // ембієнт (фонова музика) public AudioSource cricketsSource; // сверчки public Slider volumeSlider; void Start() { if (ambientSource != null) { ambientSource.loop = true; ambientSource.Play(); } if (cricketsSource != null) { cricketsSource.loop = true; cricketsSource.Play(); } if (volumeSlider != null) { volumeSlider.onValueChanged.AddListener(OnVolumeChange); } void OnVolumeChange(float value) { if (ambientSource != null) ambientSource.volume = value; if (cricketsSource != null) cricketsSource.volume = value; } } }