rj-action-library/Runtime/UI/OnSliderValueChange.cs

45 lines
684 B
C#

using Godot;
using System;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class OnSliderValueChange : Node
{
[Export]
public HSlider slider;
HSlider _connectedSlider = null;
[Export]
public RJAction onChange;
public void Update()
{
if ( _connectedSlider == slider )
{
return;
}
if ( _connectedSlider != null )
{
_connectedSlider.Changed -= OnChanged;
}
_connectedSlider = slider;
if ( _connectedSlider != null )
{
_connectedSlider.Changed += OnChanged;
}
}
void OnChanged()
{
Actions.Trigger( onChange );
}
}
}