0 votes

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:


So, how to do it in a correct way?

in Engine by (274 points)
edited by

1 Answer

0 votes
Best answer

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();


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

by (274 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.