Semi-Save childrens nodes

Godot Version

Godot 4.4

Question

Hi, I’m working on a plugin that needs to save nodes, and I already have a system for that, but I’m having a problem with the duplicate() method. My code saves the data in an array, but the children are temporarily saved. When the editor is reloaded, the child data is lost. I’ll add a part of the data saving function.

func SaveData() → void:
var auxListNode:Array
for node in NodeEditor.get_children():
if node is GraphNode or node is CinematicNode:
# duplicate the node
var dupNode=node.duplicate()
# appen to array
auxListNode.append([dupNode,node.name])
var auxConnections:Array = NodeEditor.get_connection_list() as Array
#save de data in Resource
CinematicResorse.SaveNodes(auxListNode,auxConnections,dicImportVar,dicImportTypeVar)

Then I have the option to redo the entire save so that it explicitly saves the children, but that already generated problems.

It’s not possible to save a Node to disk directly as is. You’ll need to use the PackedScene resource to save the node (and its children, check the documentation) to be able to save it to a file.