Update all resources after modifying a resource class
Godot’s resources are quite powerful. However, modifying a resource class doesn’t automatically update any corresponding
.tres
files, unless you happen to edit a scene that uses that resource in some way. This doesn’t impact runtime behavior — the game still runs as expected. But it can impact version control and result in a messier diff where seemingly unrelated files are modified, which increases the chance of merge conflicts.
A simple way to address this is to update all resources by re-saving them after modifying a resource class and check everything in with the same git commit. Godot doesn’t have that functionality built in, but it’s easy to create a script to do this.
@toolextends EditorScript## Crawls the entire codebase, loads, and re-saves every resource.## Run this script with CTRL/CMD+SHIFT+X.func_run() -> void:forfilenamein_build_file_list("res://","tres",20):varres:Resource=ResourceLoader.load(filename)ResourceSaver.save(res,res.resource_path)staticfunc_build_file_list(path:String,suffix:String,recursion_depth:int) -> Array[String]:vardir=DirAccess.open(path)ifnotdir:push_error("An error occurred when trying to access path: %s" % [path])return []varfiles:Array[String]dir.list_dir_begin()varfile_name=dir.get_next()whilefile_name!="":ifdir.current_is_dir()andrecursion_depth:varsub_dir:String="%s/%s" % [path, file_name]files.append_array(_build_file_list(sub_dir,suffix,recursion_depth - 1))eliffile_name.ends_with(suffix):varfull_path="%s/%s" % [path, file_name]files.append(full_path)file_name=dir.get_next()returnfiles
Are you using @onready to reference nodes? There’s a better way! Here’s a simple example of how many tutorials use @onready to reference nodes: That script is attached to a CanvasLayer node with a ProgressBar called HealthBar. And yet, when running the scene, it will throw an error: This is because there’s actually a spelling …
Development snapshot #4 of Godot Engine 4.1 is here. Among many other changes, it fixes a lighting issue related to using Light-only mode in CanvasItemMaterial (#44559). Unfortunately, it also introduced a UX issue with gradient color pickers (#77745), which makes it quite difficult to work with gradients at all. If you use gradients, I recommend …
I’m wrapping up development on version 1 of the Inventory System, which is currently at v1.18.1. All core functionality is in place, and it provides many quality-of-life features. The guide covers and walks through most of the code base, and the demo projects show off a lot of use cases. This first version has been …
Update all resources after modifying a resource class
Godot’s resources are quite powerful. However, modifying a resource class doesn’t automatically update any corresponding
.tres
files, unless you happen to edit a scene that uses that resource in some way. This doesn’t impact runtime behavior — the game still runs as expected. But it can impact version control and result in a messier diff where seemingly unrelated files are modified, which increases the chance of merge conflicts.A simple way to address this is to update all resources by re-saving them after modifying a resource class and check everything in with the same git commit. Godot doesn’t have that functionality built in, but it’s easy to create a script to do this.
Related Posts
Ditch @onready, use @export instead
Are you using @onready to reference nodes? There’s a better way! Here’s a simple example of how many tutorials use @onready to reference nodes: That script is attached to a CanvasLayer node with a ProgressBar called HealthBar. And yet, when running the scene, it will throw an error: This is because there’s actually a spelling …
Godot Engine 4.1.dev4 is available
Development snapshot #4 of Godot Engine 4.1 is here. Among many other changes, it fixes a lighting issue related to using Light-only mode in CanvasItemMaterial (#44559). Unfortunately, it also introduced a UX issue with gradient color pickers (#77745), which makes it quite difficult to work with gradients at all. If you use gradients, I recommend …
Inventory System v1.18.1 available (and v2 progress update)
I’m wrapping up development on version 1 of the Inventory System, which is currently at v1.18.1. All core functionality is in place, and it provides many quality-of-life features. The guide covers and walks through most of the code base, and the demo projects show off a lot of use cases. This first version has been …
Inventory System v1.9 available
Another quick inventory system update. The Resizable Container Demo now includes preliminary support for controllers. Features: Additional bug fixes: