Refactor AnimGraph debug flows to use scripting API event
This commit is contained in:
@@ -1306,22 +1306,6 @@ namespace FlaxEditor
|
||||
VisualScriptingDebugFlow?.Invoke(debugFlow);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct AnimGraphDebugFlowInfo
|
||||
{
|
||||
public Asset Asset;
|
||||
public FlaxEngine.Object Object;
|
||||
public uint NodeId;
|
||||
public int BoxId;
|
||||
}
|
||||
|
||||
internal static event Action<AnimGraphDebugFlowInfo> AnimGraphDebugFlow;
|
||||
|
||||
internal static void Internal_OnAnimGraphDebugFlow(ref AnimGraphDebugFlowInfo debugFlow)
|
||||
{
|
||||
AnimGraphDebugFlow?.Invoke(debugFlow);
|
||||
}
|
||||
|
||||
private static void RequestStartPlayOnEditMode()
|
||||
{
|
||||
if (Instance.StateMachine.IsEditMode)
|
||||
|
||||
@@ -34,7 +34,6 @@ MMethod* Internal_GetGameWinPtr = nullptr;
|
||||
MMethod* Internal_GetGameWindowSize = nullptr;
|
||||
MMethod* Internal_OnAppExit = nullptr;
|
||||
MMethod* Internal_OnVisualScriptingDebugFlow = nullptr;
|
||||
MMethod* Internal_OnAnimGraphDebugFlow = nullptr;
|
||||
MMethod* Internal_RequestStartPlayOnEditMode = nullptr;
|
||||
|
||||
void OnLightmapsBake(ShadowsOfMordor::BuildProgressStep step, float stepProgress, float totalProgress, bool isProgressEvent)
|
||||
@@ -138,38 +137,6 @@ void OnVisualScriptingDebugFlow()
|
||||
}
|
||||
}
|
||||
|
||||
struct AnimGraphDebugFlowInfo
|
||||
{
|
||||
MonoObject* Asset;
|
||||
MonoObject* Object;
|
||||
uint32 NodeId;
|
||||
int32 BoxId;
|
||||
};
|
||||
|
||||
void OnAnimGraphDebugFlow(Asset* asset, ScriptingObject* object, uint32 nodeId, uint32 boxId)
|
||||
{
|
||||
if (Internal_OnAnimGraphDebugFlow == nullptr)
|
||||
{
|
||||
Internal_OnAnimGraphDebugFlow = ManagedEditor::GetStaticClass()->GetMethod("Internal_OnAnimGraphDebugFlow", 1);
|
||||
ASSERT(Internal_OnAnimGraphDebugFlow);
|
||||
}
|
||||
|
||||
AnimGraphDebugFlowInfo flowInfo;
|
||||
flowInfo.Asset = asset ? asset->GetOrCreateManagedInstance() : nullptr;
|
||||
flowInfo.Object = object ? object->GetOrCreateManagedInstance() : nullptr;
|
||||
flowInfo.NodeId = nodeId;
|
||||
flowInfo.BoxId = boxId;
|
||||
MonoObject* exception = nullptr;
|
||||
void* params[1];
|
||||
params[0] = &flowInfo;
|
||||
Internal_OnAnimGraphDebugFlow->Invoke(nullptr, params, &exception);
|
||||
if (exception)
|
||||
{
|
||||
MException ex(exception);
|
||||
ex.Log(LogType::Error, TEXT("OnAnimGraphDebugFlow"));
|
||||
}
|
||||
}
|
||||
|
||||
void OnLogMessage(LogType type, const StringView& msg);
|
||||
|
||||
ManagedEditor::ManagedEditor()
|
||||
@@ -187,7 +154,6 @@ ManagedEditor::ManagedEditor()
|
||||
CSG::Builder::OnBrushModified.Bind<OnBrushModified>();
|
||||
Log::Logger::OnMessage.Bind<OnLogMessage>();
|
||||
VisualScripting::DebugFlow.Bind<OnVisualScriptingDebugFlow>();
|
||||
AnimGraphExecutor::DebugFlow.Bind<OnAnimGraphDebugFlow>();
|
||||
}
|
||||
|
||||
ManagedEditor::~ManagedEditor()
|
||||
@@ -204,7 +170,6 @@ ManagedEditor::~ManagedEditor()
|
||||
CSG::Builder::OnBrushModified.Unbind<OnBrushModified>();
|
||||
Log::Logger::OnMessage.Unbind<OnLogMessage>();
|
||||
VisualScripting::DebugFlow.Unbind<OnVisualScriptingDebugFlow>();
|
||||
AnimGraphExecutor::DebugFlow.Unbind<OnAnimGraphDebugFlow>();
|
||||
}
|
||||
|
||||
void ManagedEditor::Init()
|
||||
@@ -530,7 +495,6 @@ void ManagedEditor::DestroyManaged()
|
||||
Internal_GetGameWinPtr = nullptr;
|
||||
Internal_OnAppExit = nullptr;
|
||||
Internal_OnVisualScriptingDebugFlow = nullptr;
|
||||
Internal_OnAnimGraphDebugFlow = nullptr;
|
||||
|
||||
// Base
|
||||
PersistentScriptingObject::DestroyManaged();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using FlaxEditor.Content;
|
||||
using FlaxEditor.CustomEditors;
|
||||
using FlaxEditor.CustomEditors.Editors;
|
||||
@@ -13,6 +14,7 @@ using FlaxEditor.Viewport.Cameras;
|
||||
using FlaxEditor.Viewport.Previews;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
using Object = FlaxEngine.Object;
|
||||
|
||||
// ReSharper disable UnusedMember.Local
|
||||
// ReSharper disable UnusedMember.Global
|
||||
@@ -206,11 +208,18 @@ namespace FlaxEditor.Windows.Assets
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct AnimGraphDebugFlowInfo
|
||||
{
|
||||
public uint NodeId;
|
||||
public int BoxId;
|
||||
}
|
||||
|
||||
private FlaxObjectRefPickerControl _debugPicker;
|
||||
private NavigationBar _navigationBar;
|
||||
private PropertiesProxy _properties;
|
||||
private Tab _previewTab;
|
||||
private readonly List<Editor.AnimGraphDebugFlowInfo> _debugFlows = new List<Editor.AnimGraphDebugFlowInfo>();
|
||||
private readonly List<AnimGraphDebugFlowInfo> _debugFlows = new List<AnimGraphDebugFlowInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the animated model actor used for the animation preview.
|
||||
@@ -285,7 +294,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
Parent = this
|
||||
};
|
||||
|
||||
Editor.AnimGraphDebugFlow += OnDebugFlow;
|
||||
Animations.DebugFlow += OnDebugFlow;
|
||||
}
|
||||
|
||||
private void OnSurfaceContextChanged(VisjectSurfaceContext context)
|
||||
@@ -293,26 +302,27 @@ namespace FlaxEditor.Windows.Assets
|
||||
_surface.UpdateNavigationBar(_navigationBar, _toolstrip);
|
||||
}
|
||||
|
||||
private bool OnCheckValid(FlaxEngine.Object obj, ScriptType type)
|
||||
private bool OnCheckValid(Object obj, ScriptType type)
|
||||
{
|
||||
return obj is AnimatedModel player && player.AnimationGraph == OriginalAsset;
|
||||
}
|
||||
|
||||
private void OnDebugFlow(Editor.AnimGraphDebugFlowInfo flowInfo)
|
||||
private void OnDebugFlow(Asset asset, Object obj, uint nodeId, uint boxId)
|
||||
{
|
||||
// Filter the flow
|
||||
if (_debugPicker.Value != null)
|
||||
{
|
||||
if (flowInfo.Asset != OriginalAsset || _debugPicker.Value != flowInfo.Object)
|
||||
if (asset != OriginalAsset || _debugPicker.Value != obj)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flowInfo.Asset != Asset || _preview.PreviewActor != flowInfo.Object)
|
||||
if (asset != Asset || _preview.PreviewActor != obj)
|
||||
return;
|
||||
}
|
||||
|
||||
// Register flow to show it in UI on a surface
|
||||
var flowInfo = new AnimGraphDebugFlowInfo { NodeId = nodeId, BoxId = (int)boxId };
|
||||
lock (_debugFlows)
|
||||
{
|
||||
_debugFlows.Add(flowInfo);
|
||||
@@ -457,7 +467,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
/// <inheritdoc />
|
||||
public override void OnDestroy()
|
||||
{
|
||||
Editor.AnimGraphDebugFlow -= OnDebugFlow;
|
||||
Animations.DebugFlow -= OnDebugFlow;
|
||||
|
||||
_properties = null;
|
||||
_navigationBar = null;
|
||||
|
||||
Reference in New Issue
Block a user