添加程序化动画
This commit is contained in:
34
Temp/ScriptableAnimation.cs
Normal file
34
Temp/ScriptableAnimation.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Net.WebSockets;
|
||||
|
||||
namespace BITKit;
|
||||
[Tool]
|
||||
public partial class ScriptableAnimation : Node
|
||||
{
|
||||
[Export(PropertyHint.Range,"0,1")]
|
||||
public float Value
|
||||
{
|
||||
get => _value;
|
||||
set => SetValue(value);
|
||||
}
|
||||
private float _value;
|
||||
[Export] protected bool autoPlay;
|
||||
private void SetValue(float newValue)
|
||||
{
|
||||
_value =Math.Clamp(newValue,0,1);
|
||||
OnSetValue(newValue);
|
||||
}
|
||||
protected virtual void OnSetValue(float newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (autoPlay)
|
||||
{
|
||||
Value = (Value + (float)delta)%1;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user