Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document using autoloads safely in editor plugins #69387

Open
nonunknown opened this issue Nov 30, 2022 · 1 comment
Open

Document using autoloads safely in editor plugins #69387

nonunknown opened this issue Nov 30, 2022 · 1 comment

Comments

@nonunknown
Copy link
Contributor

Godot version

4.0 beta 6

System information

manjaro linux

Issue description

When a plugin uses a Singleton, you know that until the singleton is added to Autoload, the engine doesnt recognize the the name in scripts, lets take dialogic as example, it uses a singleton called: Dialogic but since you open the project the Scripts are parsed and checked, and this generates error since Singleton isnt recognized, then the engine doesnt recognizing it thus you cant enable the plugin!

workaround:

  • add the autoload manually before enabling the plugin

Steps to reproduce

  • Open Project
  • Create a new plugin
  • Make it using a singleton
  • Disable plugin
  • Close Project
  • Open Project again
  • Try to enable plugin

Minimal reproduction project

just download dialogic and place it on your project

https://github.com/coppolaemilio/dialogic

@TheDuriel
Copy link
Contributor

TheDuriel commented Nov 30, 2022

This is imho an expected environmental constraint a plugin must operate under.

The correct way to handles this, as the plugin developer, is to not rely on the name.

Neither should the user be required to add the autoload, the plugin can do that.

What to do:

In the EditorPlugin's _enter_tree(), you register the autoload under a name. This name is purely for the user, not for the plugin.

In the plugins various scripts, you add this line: var plugin_autoload: Node = $"/root/plugin_autoload", and use this variable instead of the autoloads name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants