com.alicizax.unity.animatio.../Editor/Inspector/GraphInspector.cs

45 lines
1.2 KiB
C#
Raw Permalink Normal View History

2025-02-07 16:05:13 +08:00
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();
}
}
}