alelievr / NodeGraphProcessor

Node graph editor framework focused on data processing using Unity UIElements and C# 4.6
https://github.com/alelievr/NodeGraphProcessor/projects/2
MIT License
2.28k stars 379 forks source link

CustomBehaviour Port drawers & Proxied Fields #204

Open dannymate opened 2 years ago

dannymate commented 2 years ago

Solves issue: https://github.com/alelievr/NodeGraphProcessor/issues/202.

Added showAsDrawer to portdata, I initially created it as a replacement to ShowAsDrawer attribute but it turns out for what I was doing it wasn't required but I thought it may still be useful if creating a port without a backing field and you still want a property drawer. Converted the single FieldInfo system in BaseNodeView to handle the new PortData field proxiedFieldPath. This is a path relative to the node the port is on. "fieldInNodeTarget.ChildFieldInThatField.etc.etc". I added a parser in BaseNodeView for this to create List. The methods in DrawDefaultInspector have been pertaining to AddControlField now use a List. In DrawDefaultInspector we check if it has any ports to its name and checks its portData to see if its being proxied and cycles through those. Other than some minor changes it piggybacks off of what already there this is largely due to FindSerializedProperty already uses the proxiedFieldPath format to get SeralizedProperty anyway. I have added a few extension methods to make the code more readable. I have provided an example of dynamic port generation with ProxiedFields.

image

dannymate commented 2 years ago

I've noticed a couple issues.

  1. Error on edge disconnects
  2. Error on undo

I've fixed these in my branch but I've messed this pull request up a bit so I'll create a new one.