|
32 | 32 |
|
33 | 33 | #include "editor/audio_stream_preview.h" |
34 | 34 | #include "editor/editor_help.h" |
| 35 | +#include "editor/editor_inspector.h" |
35 | 36 | #include "editor/editor_node.h" |
36 | 37 | #include "editor/editor_resource_preview.h" |
37 | 38 | #include "editor/editor_settings.h" |
@@ -486,6 +487,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { |
486 | 487 |
|
487 | 488 | Resource *resp = Object::cast_to<Resource>(obj); |
488 | 489 | ERR_BREAK(!resp); |
| 490 | + resp->set_path(_get_owner_path() + "::"); // Assign a base path for built-in Resources. |
489 | 491 |
|
490 | 492 | EditorNode::get_editor_data().instantiate_object_properties(obj); |
491 | 493 |
|
@@ -579,6 +581,32 @@ void EditorResourcePicker::_button_input(const Ref<InputEvent> &p_event) { |
579 | 581 | } |
580 | 582 | } |
581 | 583 |
|
| 584 | +String EditorResourcePicker::_get_owner_path() const { |
| 585 | + EditorProperty *property = Object::cast_to<EditorProperty>(get_parent()); |
| 586 | + if (!property) { |
| 587 | + return String(); |
| 588 | + } |
| 589 | + Object *obj = property->get_edited_object(); |
| 590 | + |
| 591 | + Node *node = Object::cast_to<Node>(obj); |
| 592 | + if (node) { |
| 593 | + if (node->get_scene_file_path().is_empty()) { |
| 594 | + node = node->get_owner(); |
| 595 | + } |
| 596 | + if (node) { |
| 597 | + return node->get_scene_file_path(); |
| 598 | + } |
| 599 | + return String(); |
| 600 | + } |
| 601 | + |
| 602 | + Resource *res = Object::cast_to<Resource>(obj); |
| 603 | + if (res && !res->is_built_in()) { |
| 604 | + return res->get_path(); |
| 605 | + } |
| 606 | + // TODO: It would be nice to handle deeper Resource nesting. |
| 607 | + return String(); |
| 608 | +} |
| 609 | + |
582 | 610 | String EditorResourcePicker::_get_resource_type(const Ref<Resource> &p_resource) const { |
583 | 611 | if (p_resource.is_null()) { |
584 | 612 | return String(); |
|
0 commit comments