How to Save and Load in Godot

Опубликовано: 26 Февраль 2026
на канале: Thomas Yanuziello
2,134
110

Create a script inheriting from resource.
Put any variables you want in the script, but only use built-in types.
Only variables with the export tag will be saved.
You can initialize the variables by overriding the _init() function.
Give your resource script a class name at the top of the script.
In a separate script, declare a variable using the resource class name as the type.
Create the resource using the class name followed by .new().
Save the resource using ResourceSaver.save(_var_name, "user://filename.res")
Load the resource using _var_name = ResourceLoader.load("user://filename.res")
Be sure to set the variables inside the resource before saving, and get their values after loading.

Patreon:   / tyanuziello  
Discord:   / discord  
Udemy
https://www.udemy.com/course/build-a-...
https://www.udemy.com/course/godot-ma...
Skillshare
https://www.skillshare.com/en/r/profi...