You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code snippet compiles in engine code, but does not compile in godot-cpp:
error: no member named 'get_singleton' in 'godot::SceneTree'
91 | SceneTree *scene_tree = SceneTree::get_singleton();
| ~~~~~~~~~~~^
1 error generated.
My use case is that I'm trying to connect to signals on SceneTree such as physics_frame.
It seems that most other singletons have this method in godot-cpp, it's just SceneTree where it's missing:
Steps to reproduce
Add SceneTree *scene_tree = SceneTree::get_singleton(); to a GDExtension godot-cpp project and try to compile it.
Minimal reproduction project
I'm not gonna bother including a minimal reproduction project since it's one line of code.
Activity
AThousandShips commentedon Sep 19, 2024
It isn't registered as a singleton, and isn't available in scripting as such, see
scene/register_scene_types.cppBenLubar commentedon Oct 7, 2024
SceneTree is accessed in GDScript via
Engine.get_main_loop().dsnopek commentedon Oct 7, 2024
Yeah, it's a workaround, but you can get the scene tree like this:
We should probably generate a
SceneTree::get_singleton()function that does this in godot-cpp, to make code compatible with modules.