Custom Plug-In Tab - saving values

Godot Version

Godot 4.3

Question

I’m working on a plugin/addon for Godot and am currently trying to setup the main editor tab for it.

I have a few basic fields where the user can enter values.
What would be the best way to save these values / make them accessible for the code when running?

image

For example if I have a checkbox that activates logging to console:

  • whats the best practice of accessing this boolean from my various scripts?
  • How can I make sure the projects saves if the user has this checked on or not (when closing/opening Godot) ?

Thanks in advance

How can I make sure the projects saves if the user has this checked on or not (when closing/opening Godot) ?

I believe a function is called when the editor needs to save/is closed: _save_external_data()

whats the best practice of accessing this boolean from my various scripts?

It depends on how you want to save it. I can think of 3 options.

  1. Have a folder in the user:// directory. But this won’t be saved to the project itself
  2. Try the @export_storage tag. This should save variables to the script itself but I have not tested it and am not sure how to directly change the script
  3. Have the save file in your addon folder. However this will only work before a project is exported

Hope this helps! =)

1 Like