Seneral / Node_Editor_Framework

A flexible and modular Node Editor Framework for creating node based displays and editors in Unity
https://nodeeditor.seneral.dev
MIT License
2k stars 415 forks source link

Node's connectionPort list is reset in playmode. #162

Closed jangofett890 closed 5 years ago

jangofett890 commented 6 years ago

Found out that GetValue from connection knob wasn't working properly as they were not designed to calculate the values automatically, rather from traversal. I started modifying the DialogNodeCanvas extension to calculate the connected nodes so Input, and other kind of nodes could be used for stat checks, etc, however for some reason all the node connection port lists are empty even though they definitely have connection ports. I've tried using ConnectionPortManager.UpdateConnectionPorts and UpdatePortLists but those functions crash the game while in play mode. UpdatePortLists crashes with stack trace: NullReferenceException: Object reference not set to an instance of an object NodeEditorFramework.ConnectionPortManager+<GetPortDeclarationEnumerator>c__Iterator0.MoveNext () (at Assets/Node_Editor/Framework/Core/ConnectionPortManager.cs:92) NodeEditorFramework.ConnectionPortManager.UpdatePortLists (NodeEditorFramework.Node node) (at Assets/Node_Editor/Framework/Core/ConnectionPortManager.cs:70)

And UpdateConnectionPorts crashes with stack trace: NullReferenceException: Object reference not set to an instance of an object NodeEditorFramework.ConnectionPortManager+<GetPortDeclarationEnumerator>c__Iterator0.MoveNext () (at Assets/Node_Editor/Framework/Core/ConnectionPortManager.cs:92) NodeEditorFramework.ConnectionPortManager.UpdateConnectionPorts (NodeEditorFramework.Node node) (at Assets/Node_Editor/Framework/Core/ConnectionPortManager.cs:48)

Seneral commented 6 years ago

Did you make sure to init the framework (or atleast that specific module) first? Either do NodeEditor.checkInit () first (you can pass false if you don't need the GUI parts of the framework) or ConnectionPortManager.FetchNodeConnectionDeclarations () directly. Then, you need to call UpdatePortLists (or UpdateConnectionPorts when you want additional verifications) for each node. As this is kind of clumsy, there are plans to work around that and make it cleaner.

Seneral commented 5 years ago

Btw you just need to call canvas.Validate() now