See all glossary terms

Resource

In Godot, a resource is a file that you can use in your game to save and load data from your hard drive. It can be an image texture, a sound effect, a scene, a script, and many other things. Like nodes, resources are a core building block of Godot games. We'll learn more about them as we go and even create our own resource types by the end of the course.
If you're coming from the Unity game engine, you can think of resources as Godot's version of Scriptable Objects. They're at the core of how Godot works, and they're used to optimize the loading and saving of almost everything you use in your game.

Resources are only loaded once

Resources implement the flyweight design pattern. It means that when you load a resource from multiple places, the engine only loads it once and retrieves the loaded resource in memory and every place that wants to access it. So, a resource is shared by default and has a small memory footprint as a result.
You can make a resource unique to each scene instance that uses it by turning on its local_to_scene property. When loading a resource from code, you can create a unique copy by calling the resource's duplicate function.

Resource extensions

There are a few extensions that Godot recognizes as resources:
  • .res is a generic resource, written in binary format (not readable by humans)
  • .tres is a generic resource, written in text format (readable by humans)
Some resources have their own optional extensions:
  • Themes can have a .theme extension
  • Animations can have a .anim extension
  • Shaders can have a .gdshader extension
  • ... and so on
These extensions are for our benefit, for better readability. Godot is fine if all resources are .tres or .res.

See Also

Related terms in the Glossary