summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-12-07 23:17:43 +0100
committerGitHub <noreply@github.com>2018-12-07 23:17:43 +0100
commit4191e5316b16d61a59df40740fd46f7b211a09fe (patch)
treec25e31f41d7a2f0f7ab6d6134b985c7f5c73a2c3
parent9b78147bce3de156eda3bd64a60133c4f2acc823 (diff)
parent19b6e601d8e0376abad48ed44357e5b801db0cb2 (diff)
Merge pull request #22437 from DualMatrix/wrong_prop_warning
Added warning when trying to load resource of wrong type in editor.
-rw-r--r--editor/editor_properties.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index c6a0eafbb0..ff7ab051b5 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -1956,6 +1956,20 @@ EditorPropertyNodePath::EditorPropertyNodePath() {
void EditorPropertyResource::_file_selected(const String &p_path) {
RES res = ResourceLoader::load(p_path);
+
+ List<PropertyInfo> prop_list;
+ get_edited_object()->get_property_list(&prop_list);
+ String type;
+
+ for (List<PropertyInfo>::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();
}