system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
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?
system
2
|
|
|
|
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.