Overwrite cached resource parameters in an editor plugin?

Godot Version

4.5 Stable

Question

I am making a graph-based dialogue plugin. Each time the user saves their work, I serialize the graph into a new resource file (EventSequence) containing all the dialogue nodes. My problem is that using ResourceSaver.save() does not immediately update the resource seen in the inspector, even though the old resource should have been completely overwritten. After saving, I still see the old resource, but with its path wiped.

How do I immediately refresh the inspector after the user saves?

func _save_graph(i: int, custom_path: String = "") -> void:
	var old_sequence := sequences[i]
	var graph := graphs[i]
	var new_sequence := graph.serialize(true)
	
	sequences[i] = new_sequence
	
	var path := custom_path
	if path.is_empty():
		path = old_sequence.resource_path
	
	new_sequence.take_over_path(path)
	ResourceSaver.save(new_sequence, path)

I found this reddit post where OP had the same problem as I did. To avoid the old cached version of the resource appearing when trying to overwrite, one must instead clear the old resource and set up the new values. This is a decent solution, and I guess it is more aligned with what the Godot shader editor uses, where a resource file is opened and each operation is instantly updated in the resource. I still wish it was possible to overwrite an old resource and see the changes instantly in scenes that reference the resource.

Refreshing the values in the inspector after saving still requires manually refolding the parameter.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.