using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; using UnityEngine.UIElements; namespace Ether { public class InspectorViewer : VisualElement { public new class UxmlFactory : UxmlFactory { } Editor editor; internal void UpdateSelection(EtherNodeView nodeView) { Clear(); Object.DestroyImmediate(editor); editor = Editor.CreateEditor(nodeView.node); IMGUIContainer container = new IMGUIContainer(() => { if (nodeView.node && editor.target) { // 使用 BeginGUI 和 EndGUI 来包裹 OnInspectorGUI 调用 EditorGUILayout.BeginVertical(); editor.OnInspectorGUI(); EditorGUILayout.EndVertical(); // 检查是否点击了 Inspector 区域 if (Event.current.type == EventType.MouseDown && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { Event.current.Use(); // 标记事件已被使用,阻止冒泡 } } }); Add(container); } } }