ResourceLoader / ResourceSaver @ vs _

Godot Version

v4.3.stable.official [77dcf97d8]

Question

When I use the ResourceSaver to save a file, the object names are prefixed with a @… If I save/reload the file they are prefixed with a _. How can I stop this from happening? My connections only work after I open/save an additional time.

Here’s the bit of code that performs these operations:

func _on_save_project_dialog_file_selected(path: String) -> void:
	var graph_data = GraphData.new()
	graph_data.connections = $GraphEdit.get_connection_list()
	for node in $GraphEdit.get_children():
		if node is GraphNode:
			var node_data = NodeData.new()
			node_data.name = node.name
			node_data.position_offset = node.position_offset
			node_data.data = node.data
			graph_data.nodes.append(node_data)
	ResourceSaver.save(graph_data, path)	


func _on_open_project_dialog_file_selected(path: String) -> void:
	var graph_data = ResourceLoader.load(path)
	open_project.emit(graph_data)

Any help is much appreciated.

The @ character in node names is reserved for auto-generated names. If you try to get the name with get_name (or access the property directly), the @ is replaced with an underscore automatically. (The same goes for a number of other characters.)

According to the documentation, you can still obtain the correct file name by means of validate_node_name.

Thank you for your time. I resolved this issue with your information. It was as simple as setting ‘name = name’ when instantiating each GraphNode