Unity graph tool solution based on different implementation now focused on Unity.Experimental.Graphview
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.2 KiB

using TNode.TNodeGraphViewImpl.Editor.NodeGraphView;
using TNode.TNodeGraphViewImpl.Editor.NodeViews;
using TNodeCore.Runtime.Models;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
using UnityEngine.UIElements;
3 years ago
namespace TNode.TNodeGraphViewImpl.Editor.Inspector{
3 years ago
public class NodeInspector:SimpleGraphSubWindow{
3 years ago
private NodeData _data;
public NodeData Data{
get => _data;
set{
_data = value;
UpdateData();
3 years ago
}
}
public IBaseNodeView BaseNodeView;
3 years ago
private void UpdateData(){
Debug.Log(_data);
3 years ago
if (_data != null){
3 years ago
RefreshInspector();
3 years ago
}
}
public NodeInspector(){
this.capabilities |= Capabilities.Resizable;
style.position = new StyleEnum<Position>(Position.Absolute);
var visualTreeAsset = Resources.Load<VisualTreeAsset>("NodeInspector");
Debug.Log(visualTreeAsset);
ConstructWindowBasicSetting();
BuildWindow(visualTreeAsset);
}
3 years ago
3 years ago
private void RefreshInspector(){
//iterate field of data and get name of every fields,create a new inspector item of appropriate type and add it to the inspector for each field
var body = this.Q("InspectorBody");
body.Clear();
body.StretchToParentSize();
// foreach (var field in _data.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public)){
// var bindingPath = field.Name;
// var type = field.FieldType;
// InspectorItemFactory inspectorItemFactory = new InspectorItemFactory();
// //Invoke generic function Create<> of default inspector item factory to create an inspector item of appropriate type by reflection
// var createdItem = inspectorItemFactory.Create(type);
// if (createdItem is { } castedItem){
// castedItem.BindingNodeData = _data;
// castedItem.BindingPath = bindingPath;
// }
// Add((VisualElement)createdItem);
// }
3 years ago
}
3 years ago
}
}