← Return to game
Log in with itch.io to leave a comment.
using UnityEngine;
using UnityEngine.UI;
public class VolumeController : MonoBehaviour
{
public AudioSource musicSource;
public Slider volumeSlider;
private void Start()
if (musicSource != null && volumeSlider != null)
volumeSlider.value = musicSource.volume;
volumeSlider.onValueChanged.AddListener(SetVolume);
}
else
Debug.LogError("AudioSource или Slider не указаны");
public void SetVolume(float volume)
if (musicSource != null)
musicSource.volume = volume;
← Return to game
Comments
Log in with itch.io to leave a comment.
using UnityEngine;
using UnityEngine.UI;
public class VolumeController : MonoBehaviour
{
public AudioSource musicSource;
public Slider volumeSlider;
private void Start()
{
if (musicSource != null && volumeSlider != null)
{
volumeSlider.value = musicSource.volume;
volumeSlider.onValueChanged.AddListener(SetVolume);
}
else
{
Debug.LogError("AudioSource или Slider не указаны");
}
}
public void SetVolume(float volume)
{
if (musicSource != null)
{
musicSource.volume = volume;
}
}
}