Godot Version
4.3-stable
Question
I have a class called World that inherits Node in C++ and in my _ready()
I print the properties of both the attached script and the class itself as follows:
void World::_ready() {
Node::_ready();
Ref<Script> script = get_script();
if(script.is_valid() && script->is_class("GDScript")) {
UtilityFunctions::print("Printing GDScript properties");
TypedArray<Dictionary> script_properties = script->get_property_list();
for(int i = 0; i < script_properties.size(); i++) {
Dictionary prop = static_cast<Dictionary>(script_properties[i]);
UtilityFunctions::print("Name: ", prop["name"],
", Type: ", prop["type"],
", Usage: ", prop["usage"]);
}
UtilityFunctions::print("\nPrinting C++ class properties");
TypedArray<Dictionary> class_properties = get_property_list();
for(int i = 0; i < class_properties.size(); i++) {
Dictionary prop = static_cast<Dictionary>(class_properties[i]);
UtilityFunctions::print("Name: ", prop["name"],
", Type: ", prop["type"],
", Usage: ", prop["usage"]);
}
}
}
In Godot, I then instiate the World class and attach the following script:
class_name test_script extends World
var field_1: int
var field_2: float
To my knowledge, when I load my scene with the World node in it it should print out all the properties of the script and the class, including the two in my script which also should have the PROPERTY_USAGE_SCRIPT_VARIABLE
usage flag which IIRC is 4096.
But when inspecting the contents of the console output none of the flags or names match up with the two variables in the script.
Console output:
Printing GDScript properties
Name: RefCounted, Type: 0, Usage: 128
Name: Resource, Type: 0, Usage: 128
Name: Resource, Type: 0, Usage: 64
Name: resource_local_to_scene, Type: 1, Usage: 6
Name: resource_path, Type: 4, Usage: 4
Name: resource_name, Type: 4, Usage: 6
Name: resource_scene_unique_id, Type: 4, Usage: 0
Name: Script, Type: 0, Usage: 128
Name: source_code, Type: 4, Usage: 0
Name: GDScript, Type: 0, Usage: 128
Name: script/source, Type: 4, Usage: 10
Printing C++ class properties
Name: World, Type: 0, Usage: 128
Name: Node, Type: 0, Usage: 128
Name: _import_path, Type: 22, Usage: 10
Name: name, Type: 21, Usage: 0
Name: unique_name_in_owner, Type: 1, Usage: 2
Name: scene_file_path, Type: 4, Usage: 0
Name: owner, Type: 24, Usage: 0
Name: multiplayer, Type: 24, Usage: 0
Name: Process, Type: 0, Usage: 64
Name: process_mode, Type: 2, Usage: 6
Name: process_priority, Type: 2, Usage: 6
Name: process_physics_priority, Type: 2, Usage: 6
Name: Thread Group, Type: 0, Usage: 256
Name: process_thread_group, Type: 2, Usage: 6
Name: process_thread_group_order, Type: 2, Usage: 0
Name: process_thread_messages, Type: 2, Usage: 0
Name: Physics Interpolation, Type: 0, Usage: 64
Name: physics_interpolation_mode, Type: 2, Usage: 6
Name: Auto Translate, Type: 0, Usage: 64
Name: auto_translate_mode, Type: 2, Usage: 6
Name: Editor Description, Type: 0, Usage: 64
Name: editor_description, Type: 4, Usage: 6
Name: script, Type: 24, Usage: 1048582
Name: world.gd, Type: 0, Usage: 128
Anyone know where I am going wrong?