0 votes

Hey All,

I have some Autoloaded Singletons added from an EditorPlugin node as well as one that I set up in the editor as a test.

In the ready function of some node, I have this:

if Engine.has_singleton("NewScript"):

NewScript is definitely there under Project Settings > Autoload. Am I confused as to how this function works? If so, how would I go about checking if a singleton exists?

Godot version 3.2.4 beta 4
in Engine by (603 points)

Are the autoloaded singletons enabled?

1 Answer

+1 vote

Those function operate on built-in engine singletons like Engine or Input, not on user's autoloads.

print(Engine.has_singleton("Engine")) # prints 'True'

For accessing autoloads one can use the name from the first column of autoload settings, e.g.


It only works if "Singleton" column is checked (it is by default).

Since autoloads are direct children of root their existence can be checked like this:

print( $"/root".has_node("NameFromFirstColumn") )

Naming of "Singleton" column in autoload settings is unfortunate. A better name would be "Global" as it adds a global reference. It wouldn't confuse people as much.
I've opened an issue on github for this:

by (2,298 points)
edited by
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 Frequently asked questions and 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 [email protected] with your username.