How to load Resource in GDNative and access it's fields?

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

I’m trying to load Resource:

Ref<Resource> Params = godot::ResourceLoader::get_singleton()->load(paramsResourcePath);

But program is crashing when I try to get Resource field like I did it in GDScript:

Params->get("DefaultRounds");

So, how to do it in a correct way?

:bust_in_silhouette: Reply From: Robotex

I found how to do it.

Firstly, I replaced all *.tres by equivalent *.gd.

Secondary, I replaced all export-variables by consts.

After that I able to do this:

  godot::Ref<godot::Script> scene = (godot::Ref<godot::Script>) godot::ResourceLoader::get_singleton()->load(paramsResourcePath);
  godot::Dictionary params = scene->get_script_constant_map();

  godot::Godot::print(params["DefaultRounds"]);

Now I can use *.gd scripts for parameters that can be changed without game recompiling.