Adaptive music and music 👍
This commit is contained in:
parent
a8ae482cbe
commit
dcffb97a3d
48 changed files with 603 additions and 24 deletions
|
|
@ -12,7 +12,7 @@ public partial class AudioSlider : HSlider
|
|||
[Export] private TYPE affects;
|
||||
public override void _Ready()
|
||||
{
|
||||
DragEnded += OnDragEnded;
|
||||
ValueChanged += OnValueChanged;
|
||||
if (affects == TYPE.SFX)
|
||||
{
|
||||
SetValueNoSignal(Settings.SFX);
|
||||
|
|
@ -23,20 +23,19 @@ public partial class AudioSlider : HSlider
|
|||
}
|
||||
}
|
||||
|
||||
private void OnDragEnded(bool hasChanged)
|
||||
private void OnValueChanged(double value)
|
||||
{
|
||||
if (hasChanged)
|
||||
if (affects == TYPE.SFX)
|
||||
{
|
||||
if (affects == TYPE.SFX)
|
||||
{
|
||||
Settings.SFX = Value;
|
||||
AudioServer.SetBusVolumeDb(2, Mathf.LinearToDb((float)Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Music = Value;
|
||||
AudioServer.SetBusVolumeDb(1, Mathf.LinearToDb((float)Value));
|
||||
}
|
||||
var volume = Mathf.LinearToDb(Mathf.Exp((float)value) - 1); ;
|
||||
Settings.SFX = value;
|
||||
AudioServer.SetBusVolumeDb(2, volume);
|
||||
}
|
||||
else
|
||||
{
|
||||
var volume = Mathf.LinearToDb(Mathf.Exp((float)value) - 1); ;
|
||||
Settings.Music = value;
|
||||
AudioServer.SetBusVolumeDb(1, volume);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue