Thanks for the help. Ok, why do I want to do this? It sounds crazy but there is a reason:
I’m writing an editor extension- a visual scripting tool. It consists of Nodes, with positions on a 2D graph. Each Node has named connections, which look like tiny boxes around each node, and store information about how nodes link together. These links are created when the user manually drags a line between the connections of two nodes.
Some of the these connections act as variable inputs for a node, and might be named, for example, “Target”. Variable input connections only accept links with Nodes of a specific kind(“Variable Nodes”), and then, only Variable Nodes that contain a specific Type variable.“Target”, for example, may only accept links with “Float Variable Nodes”.
BUT! In some cases, “Target” may need to accept links from multiple variable types, say both a “Float Variable Node” and a “Int Variable Node”. This is simply for convenience, and to keep nodes from ballooning in visual size due to having too many surrounding Connections.
If you’re still with me, bravo. Here’s where it hopefully wraps up: Included as a feature of the visual scripting editor is an API which makes it easy to write your own Nodes. Each node equates to a script file, with a Coroutine for every “input” connection. I don’t want users to have to define their connections as variables in the class. instead, I’d like to create each Connection for a node behind the scenes, when it’s created by the user in the 2D graph view. To do this, I’ll need a way to grab various information from Node classes. for example if a node script contains the following Coroutine:
public IEnumerator Start(VariableConnection Target) {
Target = 10;
string text = Target;
Fire("Out");
}
I’ll need to parse that the Node should have three connections:
- “Start” (Input Connection that’s triggered from another Node)
- “Target” (Variable Connection that accepts links from int Nodes and string Nodes)
- “Out” (Output Connection that links to another Node connection)
Right now I’m focusing on #2, trying to see if it’s even possible. I can tell that there needs to be a Variable Connection named “Target”, from the Coroutine’s arguments, but now I need to determine it’s accepted link types. I’m looking for a way to crawl through a method like the one above, and pick out that “Target” has been cast as a string, and assigned as an int.
Then I can use that information to say “Target” accepts links from int Nodes and string Nodes.
If by some miracle you’re still reading, thank you. Maybe what I’m trying to do does make some sort of sense.