How to Save and Load in Godot

How to Save and Load in Godot

Thomas Yanuziello

55 лет назад

1,033 Просмотров

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: https://www.patreon.com/TYanuziello
Discord: https://discord.gg/9PVsjYdkWj
Udemy
https://www.udemy.com/course/build-a-platformer/?referralCode=F378E90C079179433DA8
https://www.udemy.com/course/godot-masterclass/?referralCode=15C9EC5C6AB8CECBFB76
Skillshare
https://www.skillshare.com/en/r/profile/Thomas-Yanuziello/719046783
Ссылки и html тэги не поддерживаются


Комментарии: