diff --git a/Source/Editor/GUI/Timeline/AnimationTimeline.cs b/Source/Editor/GUI/Timeline/AnimationTimeline.cs
index ffc06d5d6..50e5ddfdb 100644
--- a/Source/Editor/GUI/Timeline/AnimationTimeline.cs
+++ b/Source/Editor/GUI/Timeline/AnimationTimeline.cs
@@ -36,6 +36,7 @@ namespace FlaxEditor.GUI.Timeline
if (_preview == value)
return;
_preview = value;
+ value?.PreviewActor.UpdateAnimation();
UpdatePlaybackState();
PreviewChanged?.Invoke();
}
@@ -154,6 +155,7 @@ namespace FlaxEditor.GUI.Timeline
{
if (_preview != null)
{
+ frame = Mathf.Clamp(frame, 0, DurationFrames - 1);
var time = frame / FramesPerSecond;
Editor.Internal_SetAnimationTime(Object.GetUnmanagedPtr(_preview.PreviewActor), time);
if (!_preview.PlayAnimation)
diff --git a/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs b/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs
index 27e76dbf8..ca5cd22d0 100644
--- a/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs
+++ b/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs
@@ -21,6 +21,7 @@ namespace FlaxEditor.Viewport.Previews
private StaticModel _floorModel;
private ContextMenuButton _showCurrentLODButton;
private bool _playAnimation;
+ private float _playSpeed = 1.0f;
///
/// Gets or sets the skinned model asset to preview.
@@ -46,7 +47,10 @@ namespace FlaxEditor.Viewport.Previews
{
if (_playAnimation == value)
return;
+ if (!value)
+ _playSpeed = _previewModel.UpdateSpeed;
_playAnimation = value;
+ _previewModel.UpdateSpeed = value ? _playSpeed : 0.0f;
PlayAnimationChanged?.Invoke();
}
}
@@ -56,6 +60,21 @@ namespace FlaxEditor.Viewport.Previews
///
public event Action PlayAnimationChanged;
+ ///
+ /// Gets or sets the animation playback speed.
+ ///
+ public float PlaySpeed
+ {
+ get => _playAnimation ? _previewModel.UpdateSpeed : _playSpeed;
+ set
+ {
+ if (_playAnimation)
+ _previewModel.UpdateSpeed = value;
+ else
+ _playSpeed = value;
+ }
+ }
+
///
/// Gets or sets a value indicating whether show animated model skeleton nodes debug view.
///
diff --git a/Source/Editor/Viewport/Previews/AnimationPreview.cs b/Source/Editor/Viewport/Previews/AnimationPreview.cs
index b931bacfb..6e7903c7b 100644
--- a/Source/Editor/Viewport/Previews/AnimationPreview.cs
+++ b/Source/Editor/Viewport/Previews/AnimationPreview.cs
@@ -32,8 +32,8 @@ namespace FlaxEditor.Viewport.Previews
{
Parent = playbackSpeed
};
- playbackSpeedValue.ValueChanged += () => PreviewActor.UpdateSpeed = playbackSpeedValue.Value;
- ViewWidgetButtonMenu.VisibleChanged += control => playbackSpeedValue.Value = PreviewActor.UpdateSpeed;
+ playbackSpeedValue.ValueChanged += () => PlaySpeed = playbackSpeedValue.Value;
+ ViewWidgetButtonMenu.VisibleChanged += control => playbackSpeedValue.Value = PlaySpeed;
}
// Play/Pause widget