-
Notifications
You must be signed in to change notification settings - Fork 27
Enable code to reference input port #47
Description
I assumed this would be possible but wasn't able to find any way to do it or to hack it in myself easily. Hopefully I didn't miss something obvious.
Comments on #6 and #34 make it seem like the input port is just meant to be a place to connect output ports as a reference for those fields to the node. However, a very simple use case that would fit within the intended design is a doubly-linked list, where a child node has a reference to its parent. Even if this was limited to single-connection input ports that would be very useful.
The example node is just a classic linked list node with data, next, and prev. Hypothetically in NewGraph it would look like:
[Serializable, Node(inputPortCapacity: Capacity.Single)]
public class LinkedNode : INode
{
[GraphDisplay(DisplayType.BothViews)]
Object data;
[InputPort] //A separate attribute for clarity, but conceptually the same as
//[Port(direction = PortDirection.Input, capacity = Capacity.Single)]
[SerializeReference]
LinkedNode prev;
[SerializeReference, Port]
LinkedNode next;
}
With the attribute on prev, when an output port is connected, the prev field would be set to the node that connected to it. If there was no input port attribute, it would behave as it does now.