- Home /
Casting a GraphView node using GetNodeByGuid() returns null
I'm trying to create a visual scripting tool using GraphView. I want different types of Nodes for the different options (Such as show message, add player EXP and so on). All my nodes inherit from my rpg_EventNode class, which itself inherits from the GraphView Node class.
When I go to save my event, I create a list of rpg_EventNodes.
private List<rpg_EventNode> _nodes => _eventGraph.nodes.ToList().Cast<rpg_EventNode>().ToList();
Then, when I've found the node I want to save, I need to cast it into it's specific type.
foreach (var node in _nodes)
{
switch(node.nodeType)
{
case 101 :
var messNode = (rpg_MessageEventNode) _eventGraph.GetNodeByGuid(node.GUID);
//Save node specific data
break;
//Annnnddddd so on.....
The problem is, this is returning null. Any ideas why?
Answer by unity_qrj_5UYMolP0jA · Feb 22, 2021 at 04:18 PM
Fixed it with this
rpg_ChoiceEventNode choiceNode = (rpg_ChoiceEventNode)_nodes.First(x=> x.GUID == node.GUID);
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Nodes in GraphView appear white. 0 Answers
Align content in GraphView Node 1 Answer
How can i check/wait until the gameobject will end the rotation ? 1 Answer