Is it possible to create a MainLoop Type in GDNative?

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

Hi everyone,

I’ve been playing around with the MainLoop Type to override de standard SceneTree just by creating a gdscript that extends MainLoop and giving a class_name to it. However, I was wondering, is it possible to do this from a gdnative script created in c++? Do I need any modifications to the standard process of creation of the gdnlib from the tutorials?

:bust_in_silhouette: Reply From: sash-rc

First, GDNative objects are actually a wrappers for an internal Godot’s object instances. So you cannot “override” its unexposed core behavior, for this you need to use a module.

As of normal use of callbacks like _init, _ready, or whichever ones given type is supporting, all GDNative classes (incl. MainLoop) are resembling its GDScript counterparts, so yes, it should be possible.