Go, Go, Godot!
  • 0

Update all resources after modifying a resource class

March 11, 2025

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.

@tool
extends EditorScript

## Crawls the entire codebase, loads, and re-saves every resource.
## Run this script with CTRL/CMD+SHIFT+X.


func _run() -> void:
	for filename in _build_file_list("res://", "tres", 20):
		var res: Resource = ResourceLoader.load(filename)
		ResourceSaver.save(res, res.resource_path)
	

static func _build_file_list(
	path: String, 
	suffix: String, 
	recursion_depth: int
) -> Array[String]:
	var dir = DirAccess.open(path)
	if not dir:
		push_error("An error occurred when trying to access path: %s" % [path])
		return []

	var files: Array[String]
	dir.list_dir_begin()
	var file_name = dir.get_next()
	while file_name != "":
		if dir.current_is_dir() and recursion_depth:
			var sub_dir: String = "%s/%s" % [path, file_name]
			files.append_array(_build_file_list(sub_dir, suffix, recursion_depth - 1))
		elif file_name.ends_with(suffix):
			var full_path = "%s/%s" % [path, file_name]
			files.append(full_path)
		file_name = dir.get_next()

	return files

gitgodotresourcesversion control
Posted in Godot.
Share
PreviousInventory System 2 Alpha 3 available
NextInventory System 2 Alpha 2 available

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related Posts

  • February 4, 2024

    Inventory System v1.3 available

    Another Inventory System release, and this time we’ve added support for persistence through serialization of inventory data. Features: Bug fixes:

  • August 1, 2022

    Godot Engine on the Steam Deck – Developing games on the go?

    Once I found out about the Steam Deck’s Desktop Mode, it got even more interesting. Steam Deck’s Gaming Mode vs Desktop Mode You see, the Steam Deck defaults to an analog of Big Picture mode on PC. It runs full screen in “Steam Deck gaming console” mode. But underneath all that is a Linux system …

  • January 30, 2024

    Inventory System v1.1 available

    Hot on the heels of 1.0, version 1.1 allows for gaps in the inventory. This release also correctly bakes the release version into the PDF Guide.

  • January 12, 2023

    Is Godot is the Linux of Game Engines?

    Godot Engine is an open-source game engine. With the 4.0 release on the horizon, it’ll gain quite a bit of attention. And it’s an engine worth keeping an eye on. Internet Gaming. Serious business. Game development is serious business. The global gaming market size was 203 billion USD in 2020 (per fortunebusinessinsights). It is predicted …

    © 2025 GoGoGodot.io. All rights reserved.