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

45 lines
684 B
C#
Raw Normal View History

2024-09-14 06:41:52 +00:00
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 );
}
}
}