Add AutoAttachDebugPreviewActor option to editor for quick debugging anim graphs on dynamically spawned player
This commit is contained in:
@@ -350,14 +350,14 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (PresenterContext is PropertiesWindow)
|
if (PresenterContext is PropertiesWindow || PresenterContext == null)
|
||||||
_linkedTreeNode = Editor.Instance.Scene.GetActorNode(actor).TreeNode;
|
_linkedTreeNode = Editor.Instance.Scene.GetActorNode(actor).TreeNode;
|
||||||
else if (PresenterContext is PrefabWindow prefabWindow)
|
else if (PresenterContext is PrefabWindow prefabWindow)
|
||||||
_linkedTreeNode = prefabWindow.Graph.Root.Find(actor).TreeNode;
|
_linkedTreeNode = prefabWindow.Graph.Root.Find(actor).TreeNode;
|
||||||
if (_linkedTreeNode != null)
|
if (_linkedTreeNode != null)
|
||||||
{
|
{
|
||||||
_linkedTreeNode.ExpandAllParents();
|
_linkedTreeNode.ExpandAllParents();
|
||||||
if (PresenterContext is PropertiesWindow)
|
if (PresenterContext is PropertiesWindow || PresenterContext == null)
|
||||||
Editor.Instance.Windows.SceneWin.SceneTreePanel.ScrollViewTo(_linkedTreeNode, true);
|
Editor.Instance.Windows.SceneWin.SceneTreePanel.ScrollViewTo(_linkedTreeNode, true);
|
||||||
else if (PresenterContext is PrefabWindow prefabWindow)
|
else if (PresenterContext is PrefabWindow prefabWindow)
|
||||||
(prefabWindow.Tree.Parent as Panel).ScrollViewTo(_linkedTreeNode, true);
|
(prefabWindow.Tree.Parent as Panel).ScrollViewTo(_linkedTreeNode, true);
|
||||||
@@ -427,7 +427,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
|
|
||||||
private void Select(Actor actor)
|
private void Select(Actor actor)
|
||||||
{
|
{
|
||||||
if (PresenterContext is PropertiesWindow)
|
if (PresenterContext is PropertiesWindow || PresenterContext == null)
|
||||||
Editor.Instance.SceneEditing.Select(actor);
|
Editor.Instance.SceneEditing.Select(actor);
|
||||||
else if (PresenterContext is PrefabWindow prefabWindow)
|
else if (PresenterContext is PrefabWindow prefabWindow)
|
||||||
prefabWindow.Select(prefabWindow.Graph.Root.Find(actor));
|
prefabWindow.Select(prefabWindow.Graph.Root.Find(actor));
|
||||||
|
|||||||
@@ -162,6 +162,13 @@ namespace FlaxEditor.Options
|
|||||||
[EditorDisplay("Content"), EditorOrder(550)]
|
[EditorDisplay("Content"), EditorOrder(550)]
|
||||||
public bool UseAssetImportPathRelative { get; set; } = true;
|
public bool UseAssetImportPathRelative { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If checked, editor windows will try to automatically attach to the first found valid actor for preview. For example, Animation Graph window will pick the first matching instance to preview.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(false)]
|
||||||
|
[EditorDisplay("Content"), EditorOrder(550)]
|
||||||
|
public bool AutoAttachDebugPreviewActor { get; set; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether perform automatic CSG rebuild on brush change.
|
/// Gets or sets a value indicating whether perform automatic CSG rebuild on brush change.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -415,8 +415,24 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override unsafe void OnUpdate()
|
public override unsafe void OnUpdate()
|
||||||
{
|
{
|
||||||
// Extract animations playback state from the events tracing
|
// Auto-attach preview
|
||||||
var debugActor = _debugPicker.Value as AnimatedModel;
|
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)
|
if (debugActor == null)
|
||||||
debugActor = _preview.PreviewActor;
|
debugActor = _preview.PreviewActor;
|
||||||
if (debugActor != null)
|
if (debugActor != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user