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
When I think of video games, I generally still think of an application that is downloaded and runs on the client. Technically, that’s still the case with web-based exports from Godot Engine, since the web browser has to download the files before being able to run them. I thought maybe I could just run the …
I use an app called barrier. It allows you to share your mouse and keyboard with multiple devices. I use it, because I tend to have my laptop and Macbook sitting next to my PC, and it makes working across all devices very convenient. It’s a mix of a multi-monitor and multi-computer setup. Concept Your …
A new version of the Inventory System is available with more multiplayer-related features. The Multiplayer Interaction Demo can now run in multiple modes, through two separate implementations of the Character scene: The simple character scene leverages the MultiplayerSynchronizer and can either let the client have authority and move the character, or have the client send …
One of the benefits of working with Godot Engine is that GDScript allows one to operate high level. GDScript is dynamically typed, so not even variable types have to be specified, but I would strongly recommend using static typing wherever possible. It can help with performance but primarily adds clarity when trying to follow the …
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
Quickly deploying Godot games on the web with Netlify
When I think of video games, I generally still think of an application that is downloaded and runs on the client. Technically, that’s still the case with web-based exports from Godot Engine, since the web browser has to download the files before being able to run them. I thought maybe I could just run the …
Share your Computer’s Mouse and Keyboard with your Steam Deck
I use an app called barrier. It allows you to share your mouse and keyboard with multiple devices. I use it, because I tend to have my laptop and Macbook sitting next to my PC, and it makes working across all devices very convenient. It’s a mix of a multi-monitor and multi-computer setup. Concept Your …
Inventory System v1.14 available
A new version of the Inventory System is available with more multiplayer-related features. The Multiplayer Interaction Demo can now run in multiple modes, through two separate implementations of the Character scene: The simple character scene leverages the MultiplayerSynchronizer and can either let the client have authority and move the character, or have the client send …
When not all strings are Strings. Detect bugs in your GDscript more easily with static typing
One of the benefits of working with Godot Engine is that GDScript allows one to operate high level. GDScript is dynamically typed, so not even variable types have to be specified, but I would strongly recommend using static typing wherever possible. It can help with performance but primarily adds clarity when trying to follow the …