Godot Engine – Multi-platform 2D and 3D game engine
[ObjectDB Profiler] Make easier to identify objects in the Snapshot Object View
Mariano Suligoya767fbcd29b4
diff --git a/modules/objectdb_profiler/editor/data_viewers/object_view.cpp b/modules/objectdb_profiler/editor/data_viewers/object_view.cppindex 5784a79a46c..96ca26d105a 100644--- a/modules/objectdb_profiler/editor/data_viewers/object_view.cpp+++ b/modules/objectdb_profiler/editor/data_viewers/object_view.cpp@@ -146,7 +146,13 @@ void SnapshotObjectView::_insert_data(GameStateSnapshot *p_snapshot, const Strinitem->set_auto_translate_mode(offset + 0, AUTO_TRANSLATE_MODE_DISABLED);item->set_auto_translate_mode(offset + 1, AUTO_TRANSLATE_MODE_DISABLED);item->set_text(offset + 0, pair.value->type_name);+ if (has_theme_icon(pair.value->type_name, SNAME("EditorIcons"))) {+ item->set_icon(offset + 0, get_editor_theme_icon(pair.value->type_name));+ } else {+ item->set_icon(offset + 0, get_editor_theme_icon(SNAME("Object")));+ }item->set_text(offset + 1, pair.value->get_name());+ item->set_tooltip_text(offset + 1, pair.value->remote_path);item->set_text(offset + 2, String::num_uint64(pair.value->inbound_references.size()));item->set_text(offset + 3, String::num_uint64(pair.value->outbound_references.size()));item_data_map[item] = pair.value;diff --git a/modules/objectdb_profiler/editor/snapshot_data.cpp b/modules/objectdb_profiler/editor/snapshot_data.cppindex 92df624b4a2..e7e6bff0713 100644--- a/modules/objectdb_profiler/editor/snapshot_data.cpp+++ b/modules/objectdb_profiler/editor/snapshot_data.cpp@@ -45,11 +45,26 @@ SnapshotDataObject::SnapshotDataObject(SceneDebuggerObject &p_obj, GameStateSnapsnapshot(p_snapshot) {remote_object_id = p_obj.id;type_name = p_obj.class_name;+ remote_name = vformat("<%s:%d> ", type_name, remote_object_id) + TTR("(Runtime Instance)");+ remote_path = "";+ bool is_node = ClassDB::is_parent_class(type_name, "Node");+ bool is_resource = ClassDB::is_parent_class(type_name, "Resource");for (const SceneDebuggerObject::SceneDebuggerProperty &prop : p_obj.properties) {PropertyInfo pinfo = prop.first;Variant pvalue = prop.second;+ if (is_node && pinfo.name == "name") {+ remote_name = pvalue;+ } else if (is_node && pinfo.name == "Node/path") {+ remote_path = pvalue;+ } else if (is_resource && pinfo.name == "resource_path") {+ remote_path = pvalue;+ if (!remote_path.is_empty()) {+ remote_name = remote_path.get_file();+ }+ }+if (pinfo.type == Variant::OBJECT && pvalue.is_string()) {String path = pvalue;// If a resource is followed by a ::, it is a nested resource (like a sub_resource in a .tscn file).@@ -161,6 +176,9 @@ String SnapshotDataObject::_get_script_name(Ref<Script> p_script) {}String SnapshotDataObject::get_name() {+ if (!remote_name.is_empty()) {+ return remote_name;+ }String found_type_name = type_name;// Ideally, we will name it after the script attached to it.diff --git a/modules/objectdb_profiler/editor/snapshot_data.h b/modules/objectdb_profiler/editor/snapshot_data.hindex f4b38e86d5c..9f4ab814a7b 100644--- a/modules/objectdb_profiler/editor/snapshot_data.h+++ b/modules/objectdb_profiler/editor/snapshot_data.h@@ -51,6 +51,8 @@ public:uint64_t remote_object_id = 0;String type_name;+ String remote_name;+ String remote_path;LocalVector<PropertyInfo> prop_list;HashMap<StringName, Variant> prop_values;bool _get(const StringName &p_name, Variant &r_ret) const;