| 5283 | } |
| 5284 | |
| 5285 | Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) { |
| 5286 | ERR_FAIL_NULL_V_MSG(p_object, nullptr, "Object cannot be null."); |
| 5287 | |
| 5288 | Ref<Script> scr = p_object->get_script(); |
| 5289 | |
| 5290 | const EditorDebuggerRemoteObjects *robjs = Object::cast_to<EditorDebuggerRemoteObjects>(p_object); |
| 5291 | if (robjs) { |
| 5292 | String class_name; |
| 5293 | if (scr.is_valid()) { |
| 5294 | class_name = scr->get_global_name(); |
| 5295 | |
| 5296 | if (class_name.is_empty()) { |
| 5297 | // If there is no class_name in this script we just take the script path. |
| 5298 | class_name = scr->get_path(); |
| 5299 | } |
| 5300 | } |
| 5301 | |
| 5302 | if (class_name.is_empty()) { |
| 5303 | return get_class_icon(robjs->type_name, p_fallback); |
| 5304 | } |
| 5305 | |
| 5306 | return get_class_icon(class_name, p_fallback); |
| 5307 | } |
| 5308 | |
| 5309 | if (scr.is_null() && p_object->is_class("Script")) { |
| 5310 | scr = p_object; |
| 5311 | } |
| 5312 | |
| 5313 | if (Object::cast_to<MultiNodeEdit>(p_object)) { |
| 5314 | return get_class_icon(Object::cast_to<MultiNodeEdit>(p_object)->get_edited_class_name(), p_fallback); |
| 5315 | } else { |
| 5316 | return _get_class_or_script_icon(p_object->get_class(), scr.is_valid() ? scr->get_path() : String(), p_fallback); |
| 5317 | } |
| 5318 | } |
| 5319 | |
| 5320 | Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) { |
| 5321 | ERR_FAIL_COND_V_MSG(p_class.is_empty(), nullptr, "Class name cannot be empty."); |