34 lines
631 B
C#
34 lines
631 B
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/UI/ScrollBar.cs")]
|
|
public partial class ScrollBar : Node2D
|
|
{
|
|
[Export(PropertyHint.None, "")]
|
|
private Sprite2D[] arrows;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Sprite2D bar;
|
|
|
|
public int current;
|
|
|
|
public int max = 1;
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
if (base.Visible)
|
|
{
|
|
Update();
|
|
}
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
bar.Position = new Vector2(0f, Mathf.Lerp(arrows[0].Position.Y, arrows[1].Position.Y, (float)(current + 1) / (float)(max + 1)));
|
|
}
|
|
|
|
}
|