0 votes

I am working on a game collection launcher. I have 10 existing games with Autoloaded singletons. I plan to add more in future.
I import existing games through .pck (ProjectSettings.loadresourcepack(...)), but imported games need their own singletons.

1, How can I add autoload singletons after the game (collection launcher) started?
Adding nodes to root won't make the node visible in global scope variables. (cannot access the singleton by its name)
2, Is there any way to add global scope variables?

No details about this in documents:


Godot version 3.3.3.
in Engine by (304 points)

2 Answers

0 votes
Best answer

My findings is that it is not possible to add singletons after the game started and running.

I solved that like this:
1, create placeholder/dummy singletons manually in editor before the game started.
2, Import the resources/scriptis with ProjectSettings.loadresourcepack(...) in runtime.
3, replace all singletons's script with set_script(...) in runtime.

This requires planning. Singleton names and paths must match.

by (304 points)
selected by
0 votes

Create an EditorPlugin, use its add_autoload_singleton().

by (302 points)

It is good in Editor. I am looking for a solution after the game started and running.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.