GetConnectionList and C#

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tlecuauhtli

I’m trying to use the GetConnectionList function in a project of mine, I saved the given array in an Array var called connList, till there all good but the problem comes when I want to use it, how do I convert it in a Connection Structure, so I can get the from node name?

:bust_in_silhouette: Reply From: BlueKnightOne

I know this question is over a year old, but if you Google “Godot C# GetConnectionList” you end up here as one of the top results, so I wanted to share my solution for anyone who comes across.

I don’t claim this is the best solution, or even the most correct, but it worked for me.

The following is how I get the fist from and to GraphNodes from the GraphEdit connection list:

var graph = GetNode<GraphEdit>("GraphEdit");
Array connectionList = graph.GetConnectionList;

var from = graph.GetNode<GraphNode>(
    ((Dictionary) connectionList[0])["from"].ToString()
);

var to = graph.GetNode<GraphNode>(
    ((Dictionary) connectionList[0])["to"].ToString()
);