I can write one for you using your screenshots.
@tool
extends EditorPlugin
const AUTOLOAD_GLOBAL = "Global"
func _enable_plugin() -> void:
add_autoload_singleton(AUTOLOAD_GLOBAL, "res://scenes/globals/global.tscn")
func _disable_plugin() -> void:
remove_autoload_singleton(AUTOLOAD_GLOBAL)
You can just add the other scripts yourself. So for MoneyManager:
@tool
extends EditorPlugin
const AUTOLOAD_GLOBAL = "Global"
const AUTOLOAD_MONEY_MANAGER = "MoneyManager"
func _enable_plugin() -> void:
add_autoload_singleton(AUTOLOAD_GLOBAL, "res://scenes/globals/global.tscn")
add_autoload_singleton(AUTOLOAD_MONEY_MANAGER, "res://scenes/globals/money_manager.tscn")
func _disable_plugin() -> void:
remove_autoload_singleton(AUTOLOAD_GLOBAL)
remove_autoload_singleton(AUTOLOAD_MONEY_MANAGER)
Do that for the rest. Then.
- Save this file in
res://addons/autoloads/plugin.gd - Create a file
res://addons/autoloads/plugin.cfgand put this in it:
[plugin]
name="Autoloads"
description="Our game's autoloads."
author="Catlin"
version="1.0"
script="plugin.gd"
- Go to Project → Project Settings → Plugins
- Enable your new Autoloads plugin.
- Disable the plugin to uninstall everything.
- Click on the Globals tab.
- Delete any autoloads that were not uninstalled. (We are doing a clean sweep.) Note any that didn’t get deleted automatically in case you forgot to add them to the plugin script.
- Click Close.
- Save the entire project (Ctrl+S).
- Go to Project → Reload Current Project
- Wait for the project to reload. (You should get a bunch of errors about missing things - that’s good.)
- Go to Project → Project Settings → Plugins
- Enable your new Autoloads plugin.
- Click Close.
- Save the entire project (Ctrl+S).
- Go to Project → Reload Current Project
- Wait for the project to reload.
All the errors should go away.
Commit it to a branch and have someone else check it out, and their problems with the autoloads should go away.