godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.67k stars 20.11k forks source link

`EditorPlugin.add_autoload_singleton` cause confirm save everytime when close project. #94249

Open CsloudX opened 1 month ago

CsloudX commented 1 month ago

Tested versions

v4.3.beta3.mono.official [82cedc83c]

System information

Godot v4.3.beta3.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 5GB (NVIDIA; 31.0.15.3623) - AMD Ryzen 9 3900X 12-Core Processor (24 Threads)

Issue description

image

Steps to reproduce

  1. open the MRP
  2. close the MRP
  3. Godot editor comfirm you save.

Minimal reproduction project (MRP)

PluginTest2.zip

HolonProduction commented 1 month ago

Just a guess: the autoloads are stored in the project settings, so when the editor is closed the plugin changes the project settings and maybe add_autoload_singleton does not save them, so godot prompts you to do it. Calling ProjectSettings.save() in _exit_tree could be a workaround. Don't have time to test it right now.

smedelyan commented 1 month ago

As I'm suggesting in the linked issue above, I don't believe anyone should add autoloads within _enter_tree(). If you write in GDScript, you'd better utilize _enable_plugin() for that. However, in GDExtension this function won't get called (due to a bug?), so I don't have workaround for this case.

Not sure about C#