NodeGraphProcessor icon indicating copy to clipboard operation
NodeGraphProcessor copied to clipboard

CustomBehaviour Port drawers & Proxied Fields

Open dannymate opened this issue 2 years ago • 1 comments

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<FieldInfo>. The methods in DrawDefaultInspector have been pertaining to AddControlField now use a List<FieldInfo>. 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 avatar Feb 03 '22 20:02 dannymate

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.

dannymate avatar Feb 05 '22 00:02 dannymate