In Godot 4, how do I autoload my gdnative class

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By philomelus

In Godot 3.x, you could load a gdnative class as an autoload by loading the gdns file. How is this done in Godot 4.x?

I tried creating a gdscript derived from the object, then set that as an autoload, but I cannot seem to get to it. print_tree shows my object in the root of the SceneTree, but when I call get_tree()->get_root()->get_node<Globals>("test"), or get_node<Globals>("/root/test"), it returns nullptr. When I run the scene, the debugger has lines saying that the node isn’t found. Both of those options worked with gdnative in 3.5+.

I am at a loss as to what else to try.

:bust_in_silhouette: Reply From: philomelus

I got this to work using the gdscript wrapper. I’d still like to know what the correct and/or official way of doing this is.

I renamed my Globals object to AppGlobals, then created a derived from AppGlobals with no content other then the extends AppGlobals.

I get errors in the editor, of course, since the autoloads are not loaded while editing, but when I run the project, it finds the /root/Globals as it should.