diff options
| author | Yuri Sizov <yuris@humnom.net> | 2023-07-14 21:28:02 +0200 |
|---|---|---|
| committer | Yuri Sizov <yuris@humnom.net> | 2023-07-14 21:28:02 +0200 |
| commit | c10b8ac7359175a1f5b5e2e897e943bf1c01c79e (patch) | |
| tree | ef6b97ca8d3220956ee926ab45064f00ca5bc7d2 | |
| parent | 4dc26bffeb059eafb5aab4c32d1abe8c7ba2cff6 (diff) | |
| parent | a51116c6c7127aa107791f72aa4bebf493b9ca5e (diff) | |
| download | redot-engine-c10b8ac7359175a1f5b5e2e897e943bf1c01c79e.tar.gz | |
Merge pull request #79198 from theraot/enchance_onready_drop
Make onready variables created from dropping nodes include custom types
| -rw-r--r-- | editor/plugins/script_text_editor.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 5fdfb21176..0a1f735f64 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1726,9 +1726,17 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data String variable_name = String(node->get_name()).to_snake_case().validate_identifier(); if (use_type) { - text_to_drop += vformat("@onready var %s: %s = %s%s\n", variable_name, node->get_class_name(), is_unique ? "%" : "$", path); + StringName class_name = node->get_class_name(); + Ref<Script> node_script = node->get_script(); + if (node_script.is_valid()) { + StringName global_node_script_name = node_script->get_global_name(); + if (global_node_script_name != StringName()) { + class_name = global_node_script_name; + } + } + text_to_drop += vformat("@onready var %s: %s = %c%s\n", variable_name, class_name, is_unique ? '%' : '$', path); } else { - text_to_drop += vformat("@onready var %s = %s%s\n", variable_name, is_unique ? "%" : "$", path); + text_to_drop += vformat("@onready var %s = %c%s\n", variable_name, is_unique ? '%' : '$', path); } } } else { |
