Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Design data-driven Godot 4.x games with custom Resource classes: define typed data with class_name + @export, save/load .tres/.res files, instance and duplicate resources, and load on demand with ResourceLoader (incl. threaded loading). Use when modeling items/stats/configs as data in a Godot project, creating .tres resources, or working with custom Resource subclasses and ResourceLoader/ResourceSaver.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-13 | ✗→✓ | ▲ Improved | 112% | 0% |
| case-21 | ✓→✓ | = Same ✓ | 10% | 0% |
| case-19 | ✓→✓ | = Same ✓ | 307% | 0% |
| case-20 | ✓→✓ | = Same ✓ | 31% | 0% |
| case-09 | ✓→✓ | = Same ✓ | 165% | 0% |
Model game data as reusable, Inspector-editable Resource objects instead of hard-coded values, and load/save them as .tres/.res. Targets Godot 4.3+.
data; authoring .tres files in the Inspector; or loading/saving custom resources.
When not to use: nodes/scene structure → godot-nodes-scenes; saving the player's runtime progress (engine-agnostic save format/slots) → save-systems; the C# variant of this pattern → godot-csharp.
Resource with class_name and @export fields. It now appears in the"New Resource" dialog and as an @export type, editable in the Inspector.
.tres files in the FileSystem dock (text, diff-friendly) or.res (binary, smaller/faster). Edit their fields in the Inspector — no code needed.
@export var data: ItemResource, or arrays@export var loot: Array[ItemResource].
preload (constant path) or load/ResourceLoader.load(variable path). Use threaded loading for large assets.
changes too (resources are shared references).
ResourceSaver.save.gdscript# item.gd extends Resource class_name ItemResource @export var id: StringName = &"" @export var display_name: String = "Item" @export_multiline var description: String = "" @export var icon: Texture2D @export var max_stack: int = 99 @export var value: int = 0
Create sword.tres from this class in the FileSystem dock and fill it in the Inspector.
gdscriptextends Node @export var starting_items: Array[ItemResource] = [] # drag .tres files in the Inspector func _ready() -> void: for item in starting_items: print("Have: %s (x%d max)" % [item.display_name, item.max_stack])
gdscriptfunc give_unique_copy(template: ItemResource) -> ItemResource: # true = deep copy sub-resources too; false = shallow (shares sub-resources). var copy: ItemResource = template.duplicate(true) copy.value += 5 # mutating the copy won't touch the template .tres return copy
gdscriptfunc save_config(cfg: Resource) -> void: ResourceSaver.save(cfg, "user://config.tres") # user:// = writable app data dir func load_config() -> Resource: if ResourceLoader.exists("user://config.tres"): return ResourceLoader.load("user://config.tres") return null
.tres assigned to many nodes is thesame object — mutating it changes all of them (and re-saving the file). Call duplicate(true) for per-instance state.
class_name required to instance from the editor. Without it the class won't appearin the "New Resource" dialog or as an @export type.
res:// is read-only in exported games. Write runtime data to user://, neverres://. ResourceSaver.save to res:// only works in the editor.
scene nodes. Reference scenes via PackedScene, not node instances.
data graphs acyclic or use IDs/lookups.
preload vs load. preload needs a constant path and loads with the script;load accepts a variable path at runtime. Use ResourceLoader.exists() before load to avoid errors on missing files.
.tres — they ship in plain text inside the export.load_threaded_request), @tool resources with customsetup, custom ResourceFormatLoader/Saver, resource-local-to-scene, and resource UIDs, read references/resource-patterns.md.
godot-gdscript — @export annotations used to define resource fields.godot-nodes-scenes — instancing scenes vs. sharing resource data.save-systems — persisting runtime progress (separate from static data).unity-scriptableobjects — the equivalent data-asset pattern in Unity.Other measured skills in the registry, with their headline benchmark lift.