mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 18:15:53 +00:00
Volume Sliders
This commit is contained in:
parent
bc2c3de525
commit
c75d9d226f
19 changed files with 257 additions and 49 deletions
23
Scripts/UI/AudioSlider.cs
Normal file
23
Scripts/UI/AudioSlider.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue