Skip to content

Commit 77627d0

Browse files
committed
Merge pull request godotengine#115158 from timothyqiu/drop-type-inherit
Take custom type of parent scripts into account when dropping onready variables
2 parents fcb885e + b975e64 commit 77627d0

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

editor/script/script_text_editor.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,14 +2443,13 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
24432443

24442444
String variable_name = String(node->get_name()).to_snake_case().validate_unicode_identifier();
24452445
if (use_type) {
2446-
StringName class_name = node->get_class_name();
2446+
StringName custom_class_name;
24472447
Ref<Script> node_script = node->get_script();
2448-
if (node_script.is_valid()) {
2449-
StringName global_node_script_name = node_script->get_global_name();
2450-
if (!global_node_script_name.is_empty()) {
2451-
class_name = global_node_script_name;
2452-
}
2448+
while (node_script.is_valid() && custom_class_name.is_empty()) {
2449+
custom_class_name = node_script->get_global_name();
2450+
node_script = node_script->get_base_script();
24532451
}
2452+
const StringName class_name = custom_class_name.is_empty() ? node->get_class_name() : custom_class_name;
24542453
text_to_drop += vformat("@onready var %s: %s = %c%s", variable_name, class_name, is_unique ? '%' : '$', path);
24552454
} else {
24562455
text_to_drop += vformat("@onready var %s = %c%s", variable_name, is_unique ? '%' : '$', path);

0 commit comments

Comments
 (0)