Skip to content

Dynamic Value Ports

CoffeeVampir3 edited this page Mar 29, 2021 · 4 revisions
public abstract class DynamicValuePort : BasePort

This is the usage page, for API see: Dynamic Value Port API

Dynamic Value Port

Dynamic Value ports work exactly the same way that value ports do, except you can create additional ports on-the-fly in the editor. These are extremely useful if you want to create branching choices or index-sensitive logic.

The only special element you'll find in dynamic ports that is different from your typical use is that links have a DynamicIndex you can reference:

int targetIndex = 4;
foreach (var link in stringOutputWW2.Links)
{
    if (link.PortIndex != targetIndex) continue; //If this link's dynamic index is not 4, continue.
    if(stringOutputWW2.TryGetValue(link, out var val))
    {
        Debug.Log(val);
    }
    return link.Node;
}

This code will output the value of all links connected to dynamic port #4. Dynamic ports are 0 indexed, here's an illustration: 0 Index Example