initial commit
This commit is contained in:
35
Assets/Scripts/Player/PlayerAmbientSound.cs
Normal file
35
Assets/Scripts/Player/PlayerAmbientSound.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user