|
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"
|
@@ -496,6 +497,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
|
496 | 497 |
|
497 | 498 | Resource *resp = Object::cast_to<Resource>(obj);
|
498 | 499 | ERR_BREAK(!resp);
|
| 500 | + resp->set_path(_get_owner_path() + "::"); // Assign a base path for built-in Resources. |
499 | 501 |
|
500 | 502 | EditorNode::get_editor_data().instantiate_object_properties(obj);
|
501 | 503 |
|
@@ -589,6 +591,32 @@ void EditorResourcePicker::_button_input(const Ref<InputEvent> &p_event) {
|
589 | 591 | }
|
590 | 592 | }
|
591 | 593 |
|
| 594 | +String EditorResourcePicker::_get_owner_path() const { |
| 595 | + EditorProperty *property = Object::cast_to<EditorProperty>(get_parent()); |
| 596 | + if (!property) { |
| 597 | + return String(); |
| 598 | + } |
| 599 | + Object *obj = property->get_edited_object(); |
| 600 | + |
| 601 | + Node *node = Object::cast_to<Node>(obj); |
| 602 | + if (node) { |
| 603 | + if (node->get_scene_file_path().is_empty()) { |
| 604 | + node = node->get_owner(); |
| 605 | + } |
| 606 | + if (node) { |
| 607 | + return node->get_scene_file_path(); |
| 608 | + } |
| 609 | + return String(); |
| 610 | + } |
| 611 | + |
| 612 | + Resource *res = Object::cast_to<Resource>(obj); |
| 613 | + if (res && !res->is_built_in()) { |
| 614 | + return res->get_path(); |
| 615 | + } |
| 616 | + // TODO: It would be nice to handle deeper Resource nesting. |
| 617 | + return String(); |
| 618 | +} |
| 619 | + |
592 | 620 | String EditorResourcePicker::_get_resource_type(const Ref<Resource> &p_resource) const {
|
593 | 621 | if (p_resource.is_null()) {
|
594 | 622 | return String();
|
|
0 commit comments