[SOLVED]How to load Resource (Scene) using GDnative C++

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

Greetings!
I am trying to replicate This Singleton Example using c++ with GDNative, but i haven’t been able to find out how to do this part

var s = ResourceLoader.load(path)

# Instance the new scene.
current_scene = s.instance()

# Add it to the active scene, as child of root.
get_tree().get_root().add_child(current_scene)

Any help would be greatly appreciated.
Thank you.

:bust_in_silhouette: Reply From: SergLoff

A reddit user gave me the solution so in case somebody ever needs it I’m going to post it here.

CurrentScene->free();
ResourceLoader* reLo = ResourceLoader::get_singleton();
Ref<PackedScene> res = reLo->load(path);
CurrentScene = res->instance();

get_tree()->get_root()->add_child(CurrentScene);
get_tree()->set_current_scene(CurrentScene);

Cheers!

Any link from the reddit user you’re mentioning or is it a private?

KramchayDig | 2020-05-08 12:11