diff --git a/Source/Editor/Surface/AnimGraphSurface.cs b/Source/Editor/Surface/AnimGraphSurface.cs
index d7746662f..ccd78412a 100644
--- a/Source/Editor/Surface/AnimGraphSurface.cs
+++ b/Source/Editor/Surface/AnimGraphSurface.cs
@@ -113,6 +113,25 @@ namespace FlaxEditor.Surface
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
}
+ internal AnimGraphTraceEvent[] LastTraceEvents;
+
+ internal bool TryGetTraceEvent(SurfaceNode node, out AnimGraphTraceEvent traceEvent)
+ {
+ if (LastTraceEvents != null)
+ {
+ foreach (var e in LastTraceEvents)
+ {
+ if (e.NodeId == node.ID)
+ {
+ traceEvent = e;
+ return true;
+ }
+ }
+ }
+ traceEvent = default;
+ return false;
+ }
+
private static SurfaceStyle CreateStyle()
{
var editor = Editor.Instance;
@@ -383,6 +402,7 @@ namespace FlaxEditor.Surface
}
ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin;
_nodesCache.Wait();
+ LastTraceEvents = null;
base.OnDestroy();
}
diff --git a/Source/Editor/Surface/Archetypes/Animation.cs b/Source/Editor/Surface/Archetypes/Animation.cs
index 446883406..c659b475a 100644
--- a/Source/Editor/Surface/Archetypes/Animation.cs
+++ b/Source/Editor/Surface/Archetypes/Animation.cs
@@ -36,6 +36,7 @@ namespace FlaxEditor.Surface.Archetypes
{
private AssetSelect _assetSelect;
private Box _assetBox;
+ private ProgressBar _playbackPos;
///
public Sample(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
@@ -93,6 +94,36 @@ namespace FlaxEditor.Surface.Archetypes
_assetSelect.Visible = !box.HasAnyConnection;
UpdateTitle();
}
+
+ ///
+ public override void Update(float deltaTime)
+ {
+ // Debug current playback position
+ if (((AnimGraphSurface)Surface).TryGetTraceEvent(this, out var traceEvent) && traceEvent.Asset is FlaxEngine.Animation anim)
+ {
+ if (_playbackPos == null)
+ {
+ _playbackPos = new ProgressBar
+ {
+ SmoothingScale = 0.0f,
+ Offsets = Margin.Zero,
+ AnchorPreset = AnchorPresets.HorizontalStretchBottom,
+ Parent = this,
+ Height = 12.0f,
+ };
+ _playbackPos.Y -= 16.0f;
+ }
+ _playbackPos.Visible = true;
+ _playbackPos.Maximum = anim.Duration;
+ _playbackPos.Value = traceEvent.Value; // AnimGraph reports position in animation frames, not time
+ }
+ else if (_playbackPos != null)
+ {
+ _playbackPos.Visible = false;
+ }
+
+ base.Update(deltaTime);
+ }
}
///
diff --git a/Source/Editor/Windows/Assets/AnimationGraphWindow.cs b/Source/Editor/Windows/Assets/AnimationGraphWindow.cs
index 12eac22b5..e0d8c9ded 100644
--- a/Source/Editor/Windows/Assets/AnimationGraphWindow.cs
+++ b/Source/Editor/Windows/Assets/AnimationGraphWindow.cs
@@ -396,6 +396,16 @@ namespace FlaxEditor.Windows.Assets
///
public override void OnUpdate()
{
+ // Extract animations playback state from the events tracing
+ var debugActor = _debugPicker.Value as AnimatedModel;
+ if (debugActor == null)
+ debugActor = _preview.PreviewActor;
+ if (debugActor != null)
+ {
+ debugActor.EnableTracing = true;
+ Surface.LastTraceEvents = debugActor.TraceEvents;
+ }
+
base.OnUpdate();
// Update graph execution flow debugging visualization
@@ -416,6 +426,8 @@ namespace FlaxEditor.Windows.Assets
///
public override void OnDestroy()
{
+ if (IsDisposing)
+ return;
Animations.DebugFlow -= OnDebugFlow;
_properties = null;