45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using System;
|
||
using System.Linq;
|
||
using AlicizaX.AnimationFlow.Runtime;
|
||
using Sirenix.OdinInspector.Editor;
|
||
using UnityEditor;
|
||
using UnityEngine;
|
||
using UnityEngine.UIElements;
|
||
|
||
namespace AlicizaX.AnimationFlow.Editor
|
||
{
|
||
public class GraphInspector : VisualElement
|
||
{
|
||
private PropertyTree propertyTree;
|
||
|
||
public void DrawNode(NodeView nodeView)
|
||
{
|
||
Clear();
|
||
if (nodeView.actionNode == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
// 使用 Odin PropertyTree 来处理非 UnityEngine.Object 对象
|
||
propertyTree = PropertyTree.Create(nodeView.actionNode);
|
||
|
||
var imguiContainer = new IMGUIContainer(() =>
|
||
{
|
||
if (propertyTree == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
propertyTree.Draw(false);
|
||
// 手动调用 Odin 的 Apply,处理数据更新后的逻辑
|
||
if (propertyTree.ApplyChanges())
|
||
{
|
||
nodeView.RefreshState();
|
||
}
|
||
});
|
||
|
||
Add(imguiContainer);
|
||
propertyTree.Dispose();
|
||
}
|
||
}
|
||
} |