From 442dd8a1ee3e83fd4d4401ed235a3681fc8d2f9f Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Wed, 2 Jul 2025 12:14:08 -0300 Subject: [PATCH] Show custom class name in the remote inspector --- editor/debugger/editor_debugger_inspector.cpp | 104 +++++++++++------- 1 file changed, 66 insertions(+), 38 deletions(-) diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 49fd274e4e..887937d077 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -47,7 +47,7 @@ bool EditorDebuggerRemoteObjects::_set_impl(const StringName &p_name, const Vari return false; } - // Change it back to the real name when fetching. + // Change it back to the real name when sending it. if (name == "Script") { name = "script"; } else if (name.begins_with("Metadata/")) { @@ -72,18 +72,10 @@ bool EditorDebuggerRemoteObjects::_set_impl(const StringName &p_name, const Vari } bool EditorDebuggerRemoteObjects::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; - if (!prop_values.has(name)) { + if (!prop_values.has(p_name)) { return false; } - // Change it back to the real name when fetching. - if (name == "Script") { - name = "script"; - } else if (name.begins_with("Metadata/")) { - name = name.replace_first("Metadata/", "metadata/"); - } - r_ret = prop_values[p_name][remote_object_ids[0]]; return true; } @@ -200,34 +192,6 @@ EditorDebuggerRemoteObjects *EditorDebuggerInspector::set_objects(const Array &p remote_objects_list.push_back(remote_objects); } - StringName class_name = objects[0].class_name; - if (class_name != SNAME("Object")) { - // Search for the common class between all selected objects. - bool check_type_again = true; - while (check_type_again) { - check_type_again = false; - - if (class_name == SNAME("Object") || class_name == StringName()) { - // All objects inherit from Object, so no need to continue checking. - class_name = SNAME("Object"); - break; - } - - // Check that all objects inherit from type_name. - for (const SceneDebuggerObject &obj : objects) { - if (obj.class_name == class_name || ClassDB::is_parent_class(obj.class_name, class_name)) { - continue; // class_name is the same or a parent of the object's class. - } - - // class_name is not a parent of the node's class, so check again with the parent class. - class_name = ClassDB::get_parent_class(class_name); - check_type_again = true; - break; - } - } - } - remote_objects->type_name = class_name; - // Search for properties that are present in all selected objects. struct UsageData { int qty = 0; @@ -311,6 +275,70 @@ EditorDebuggerRemoteObjects *EditorDebuggerInspector::set_objects(const Array &p remote_objects->prop_values[pinfo.name] = KV.value.values; } + StringName class_name = objects[0].class_name; + bool has_custom_class = true; + + if (usage.has("Script")) { + // Check if all objects have the same script. + Ref