From 19b6e601d8e0376abad48ed44357e5b801db0cb2 Mon Sep 17 00:00:00 2001 From: DualMatrix Date: Wed, 26 Sep 2018 00:20:06 +0200 Subject: [PATCH] Added warning when trying to load resource of wrong type in editor. Added warning when trying to load resource of wrong type in editor. --- editor/editor_properties.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 3439133809d..0975cf10f86 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -1899,6 +1899,20 @@ EditorPropertyNodePath::EditorPropertyNodePath() { void EditorPropertyResource::_file_selected(const String &p_path) { RES res = ResourceLoader::load(p_path); + + List prop_list; + get_edited_object()->get_property_list(&prop_list); + String type; + + for (List::Element *E = prop_list.front(); E; E = E->next()) { + if (E->get().name == get_edited_property() && (E->get().hint & PROPERTY_HINT_RESOURCE_TYPE)) { + type = E->get().hint_string; + } + } + + if (!type.empty() && !res->is_class(type)) + EditorNode::get_singleton()->show_warning(vformat(TTR("The selected resource (%s) does not match the type expected for this property (%s)."), res->get_class(), type)); + emit_signal("property_changed", get_edited_property(), res); update_property(); }