How do I access a user defined AutoLoad script Singleton from C++

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By chanon
:warning: Old Version Published before Godot 3 was released.

I tried:

Object* MyScriptSingleton = 
Globals::get_singleton()->get_singleton_object("MyScriptSingleton");

but it doesn’t work.

:bust_in_silhouette: Reply From: chanon

I figured it out.

The correct method is:

Object* MyScriptSingleton = 
    get_tree()->get_root()->get_node(NodePath("MyScriptSingleton"));