Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable code to reference input port #47

Open
Appleguysnake opened this issue Mar 31, 2024 · 0 comments
Open

Enable code to reference input port #47

Appleguysnake opened this issue Mar 31, 2024 · 0 comments

Comments

@Appleguysnake
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant