36 lines
890 B
C#
36 lines
890 B
C#
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;
|
|
}
|
|
}
|
|
}
|