添加程序化动画
This commit is contained in:
33
Mods/工业数据采集与分析应用分享/Scripts/ProductionAnimation.cs
Normal file
33
Mods/工业数据采集与分析应用分享/Scripts/ProductionAnimation.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace BITKit;
|
||||
[Tool]
|
||||
public partial class ProductionAnimation : ScriptableAnimation
|
||||
{
|
||||
[Export] protected ProgressBar progressBar;
|
||||
[Export] protected Godot.Collections.Array<NodePath> visibleNodes;
|
||||
protected override void OnSetValue(float newValue)
|
||||
{
|
||||
if (Engine.IsEditorHint()) return;
|
||||
if (progressBar is null)
|
||||
{
|
||||
throw new Exception($"ProgressBar is Null");
|
||||
}
|
||||
for (var i = 0; i < visibleNodes.Count; i++)
|
||||
{
|
||||
var currentNode =GetNode<Control>( visibleNodes[i]);
|
||||
var threshold = (i+1) / (float)visibleNodes.Count * 100;
|
||||
GD.Print($"当前Node:{currentNode.Name},阈值{threshold} / {newValue}");
|
||||
if (threshold <= newValue)
|
||||
{
|
||||
currentNode.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentNode.Hide();
|
||||
}
|
||||
}
|
||||
progressBar.Value = newValue;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user