Skip to content

Commit 99048e6

Browse files
committed
feat: add progress bar for animation clip playable node
1 parent 2266cfb commit 99048e6

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

Editor/Scripts/GraphView/PlayableGraphView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public PlayableGraphView()
2121
{
2222
this.AddManipulator(new ContentDragger());
2323
//this.AddManipulator(new SelectionDragger());
24-
//this.AddManipulator(new RectangleSelector());
24+
this.AddManipulator(new RectangleSelector());
2525
SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale);
2626
}
2727

Editor/Scripts/Node/AnimationClipPlayableNode.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
using System.Text;
2+
using UnityEditor.UIElements;
23
using UnityEngine.Animations;
34
using UnityEngine.Playables;
45

56
namespace GBG.PlayableGraphMonitor.Editor.Node
67
{
78
public class AnimationClipPlayableNode : PlayableNode
89
{
10+
private ProgressBar _progressBar;
11+
12+
913
public AnimationClipPlayableNode(Playable playable) : base(playable)
1014
{
15+
_progressBar = new ProgressBar();
16+
// insert between title and port container
17+
titleContainer.parent.Insert(1, _progressBar);
18+
}
19+
20+
public override void Update()
21+
{
22+
if (Playable.IsValid())
23+
{
24+
var clipPlayable = (AnimationClipPlayable)Playable;
25+
var clip = clipPlayable.GetAnimationClip();
26+
var duration = clip ? clip.length : float.PositiveInfinity;
27+
var progress = (float)(Playable.GetTime() / duration) % 1.0f * 100;
28+
_progressBar.SetValueWithoutNotify(progress);
29+
_progressBar.MarkDirtyRepaint();
30+
}
31+
32+
base.Update();
1133
}
1234

1335

0 commit comments

Comments
 (0)