Siccity / xNode

Unity Node Editor: Lets you view and edit node graphs inside Unity
MIT License
3.34k stars 591 forks source link

NodeGraph.nodes created as Node type #323

Closed Lunacie closed 3 years ago

Lunacie commented 3 years ago

Hi, Everything used to work just fine, until I changed my BaseNode which inherits from Xnode.Node. For exemple, doing : foreach (BaseNode b in graph.nodes) {} b is null, it seems like the nodes no longer inherit the types on creation, and therefore cannot be cast back into a derived class.

Any idea what is causing this issue, and how to fix it ? Thank you in advance.

Lunacie commented 3 years ago

It also seems like neither public virtual Node AddNode(Type type) nor public T AddNode<T>() where T : Node are called on node creation.

pencilking2002 commented 3 years ago

@Lunacie Not sure if this is your issue but are you sure all the nodes within graph.nodes are of type BaseNode? I had an issue earlier where I was using the xNodeGroups plugin so I can group my nodes and I didn't realize that a group was also a node.

Lunacie commented 3 years ago

No , I am not using the xNodeGroups plugin. And it used to work perfectly, the only thing I did was changing the BaseClass, and then returning it to normal. Basically, nothing changed, but the nodes have became unexploitable.

Lunacie commented 3 years ago

Basically, I've lost all the data of the nodes. That's about 120 hours worth of work, and I can't find a way to get the types back. All the nodes are simply assumed to be Xnode.Node. That's it.

If there is no way to fix this issue, can someone suggest an alternative way to get the data back from the graph ?

Siccity commented 3 years ago

Just to check common errors:

The data of the graph is stored in and .asset file. If you are using text serialization you can simply open it up in your IDE and view the data that's stored in there. Search for a known name or value of some of your lost nodes and see if they're still in there. Make a backup perhaps. Across the file there should be several instances of m_Script: {some value} containing a guid. Check that these guids match the .meta files of the scripts they're supposed to be using. If for some reason the guids don't match you can try manually edit it in the .asset file. Possibly via a find and replace.

pencilking2002 commented 3 years ago

@Lunacie Just to add to @Siccity's comment, I did a test where I created a graph called SampleNodeGraph and a node type called SampleNode. Then I changed the name of the SampleNode class but didn't change the name of the class file. So now, the class name and file name are mismatched. I observed that all the nodes in my graph disappeared. I then fixed the naming issue back so that the file and class named matched but when I looked at my graph again, the nodes still didn't show up on the graph.

To fix this, I selected the Scriptable Object asset that represents my SampleNodeGraph and made sure that the nodes list was populated with all my nodes, then the graph showed my nodes again.

So the point is that if the node list on your graph asset becomes empty, you might need to populate it by hand in order to make your nodes show on the graph and also so you can access them via code. Hope this helps!

Lunacie commented 3 years ago

Changing the m_Script values in the asset file fixed it. Thank you so much, Siccity.

Siccity commented 3 years ago

Glad you got it working again. Mismatched .meta files usually happen when you rename a script from other places than through Unity