gamedev-skills/awesome-gamedev-agent-skills / skills/godot/godot-resources
godot-resources
VerifiedGodot 4.7 data-driven design with custom Resources: class_name and @export fields, .tres files, shared references vs duplicate_deep(), uids and threaded loading. Use for items, stats or enemy configs as data, or when editing one enemy changes every enemy or a .tres stops loading. Not for save slots (`save-systems`) or the C# version (`godot-csharp`).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.5 KB |
| references/resource-patterns.md | markdown | 3.7 KB |
references/resource-patterns.md
View on GitHub# Resource patterns reference (Godot 4.7)
Depth companion to `godot-resources`.
## File formats
- `.tres` — text resource. Human-readable, merges/diffs well in version control. Default
for hand-authored data.
- `.res` — binary resource. Smaller and faster to load; use for large/generated data.
- Convert by re-saving with the desired extension via `ResourceSaver.save`.
## Threaded (background) loading
Avoid frame hitches when loading large scenes/assets:
```gdscript
const PATH := "res://levels/big_level.tscn"
func begin_load() -> void:
ResourceLoader.load_threaded_request(PATH)
func _process(_delta: float) -> void:
var progress := []
match ResourceLoader.load_threaded_get_status(PATH, progress):
ResourceLoader.THREAD_LOAD_IN_PROGRESS:
update_bar(progress[0]) # 0.0–1.0
ResourceLoader.THREAD_LOAD_LOADED:
set_process(false) # after load_threaded_get the status
var res := ResourceLoader.load_threaded_get(PATH) # turns INVALID_RESOURCE
_on_loaded(res)
ResourceLoader.THREAD_LOAD_FAILED, ResourceLoader.THREAD_LOAD_INVALID_RESOURCE:
set_process(false)
push_error("Load failed")
```
## resource_local_to_scene
By default a `.tres` is shared by every scene that references it. Tick **Local to Scene**
(or set `resource_local_to_scene = true`) so each scene instance gets its own copy at load
time — useful for per-instance materials/state without manual `duplicate()`.
## @tool resources
Add `@tool` to a Resource script to run setup in the editor (e.g. validate fields, derive
values). Guard with `Engine.is_editor_hint()` where needed. Combine with `@export_tool_button`
(4.4+) or a custom inspector plugin for editor actions.
## Custom ResourceFormatLoader / Saver
To load a non-Godot file format as a Resource (e.g. a custom `.deck` text format), register
a `ResourceFormatLoader` (and optionally `ResourceFormatSaver`) and add it with
`ResourceLoader.add_resource_format_loader(loader)`. Override `_get_recognized_extensions`,
`_handles_type`, `_get_resource_type`, and `_load`. This lets `load("res://x.deck")` return your resource type.
## Resource UIDs
Godot 4 assigns each resource a stable UID (`uid://...`). Scenes can reference by UID so
moving/renaming files doesn't break links. Get one with `ResourceUID`. Imported assets keep
their UID in the `.import` file; since 4.4, scripts and shaders get a sidecar
`<file>.uid` (e.g. `player.gd.uid`). **Commit `.uid` files** (never add `*.uid` to
`.gitignore`) and move them together with their file when moving outside the editor.
Prefer letting the editor manage UIDs; avoid hand-editing `.uid` files.
## Data-driven design tips
- Keep resources **pure data**; put behavior in nodes/systems that read them. This keeps
data hot-swappable and testable.
- Use `StringName` (`&"id"`) for identifiers/keys — faster comparisons than `String`.
- Model registries (all items, all enemies) as an `Array[YourResource]` exported on an
autoload, or a directory of `.tres` files loaded at startup.
- A typed export array (`@export var loot: Array[ItemResource]`) enforces element type in
the Inspector and prevents dragging the wrong resource type.
## Common API
```gdscript
res.duplicate(deep := false) # copy; deep copies arrays/dicts + embedded sub-resources
res.duplicate_deep(Resource.DEEP_DUPLICATE_ALL) # also copies sub-resources saved to files
res.take_over_path("res://x.tres")
res.resource_path # where it loaded from ("" if in-memory)
ResourceLoader.exists(path, type_hint := "")
ResourceLoader.load(path, type_hint := "", cache_mode := CACHE_MODE_REUSE)
ResourceSaver.save(res, path, flags := 0) # FLAG_COMPRESS, FLAG_BUNDLE_RESOURCES, ...
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |