mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
23 lines
No EOL
608 B
C#
23 lines
No EOL
608 B
C#
using Godot;
|
|
|
|
namespace Cirno.Scripts.UI;
|
|
|
|
public partial class AudioSlider : HSlider
|
|
{
|
|
[Export] public StringName AudioBusName { get; private set; } = "Master";
|
|
|
|
private int _audioBusIndex;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_audioBusIndex = AudioServer.GetBusIndex(AudioBusName);
|
|
this.Value = AudioServer.GetBusVolumeLinear(_audioBusIndex);
|
|
|
|
this.ValueChanged += MusicVolumeSliderOnValueChanged;
|
|
}
|
|
|
|
private void MusicVolumeSliderOnValueChanged(double value)
|
|
{
|
|
AudioServer.SetBusVolumeLinear(_audioBusIndex, (float)value);
|
|
}
|
|
} |