Add AutoAttachDebugPreviewActor option to editor for quick debugging anim graphs on dynamically spawned player

This commit is contained in:
Wojtek Figat
2025-04-08 22:44:31 +02:00
parent c75b33eb7d
commit eb86002fbd
3 changed files with 27 additions and 4 deletions

View File

@@ -415,8 +415,24 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override unsafe void OnUpdate()
{
// Extract animations playback state from the events tracing
// Auto-attach preview
var debugActor = _debugPicker.Value as AnimatedModel;
if (!debugActor && Editor.IsPlayMode && Editor.Options.Options.General.AutoAttachDebugPreviewActor)
{
var animationGraph = OriginalAsset;
var animatedModels = Level.GetActors<AnimatedModel>();
foreach (var animatedModel in animatedModels)
{
if (animatedModel.AnimationGraph == animationGraph &&
animatedModel.IsActiveInHierarchy)
{
_debugPicker.Value = animatedModel;
break;
}
}
}
// Extract animations playback state from the events tracing
if (debugActor == null)
debugActor = _preview.PreviewActor;
if (debugActor != null)