com.alicizax.unity.animatio.../Editor/Inspector/GraphInspector.cs
陈思海 11e5744b46 init
2025-02-07 16:05:13 +08:00

45 lines
1.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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();
}
}
}