summaryrefslogtreecommitdiffstats
path: root/editor/editor_inspector.cpp
diff options
context:
space:
mode:
authorYevhen Babiichuk (DustDFG) <dfgdust@gmail.com>2024-10-01 20:03:21 +0300
committerYevhen Babiichuk (DustDFG) <dfgdust@gmail.com>2024-10-19 09:51:12 +0300
commitedde380e9cb1545d77e99bba99aaf55f55e7dc86 (patch)
tree33ac53a82a874be6b890ab959179a45625ce9764 /editor/editor_inspector.cpp
parent44fa552343722bb048e2d7c6d3661174a95a8a3c (diff)
downloadredot-engine-edde380e9cb1545d77e99bba99aaf55f55e7dc86.tar.gz
Editor: forbid deleting inherited metadata properties
Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com> Co-authored-by: Tomek <kobewi4e@gmail.com>
Diffstat (limited to 'editor/editor_inspector.cpp')
-rw-r--r--editor/editor_inspector.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 21f67772ea..e6553cc92b 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -3401,6 +3401,14 @@ void EditorInspector::update_tree() {
editors.append_array(late_editors);
+ const Node *node = Object::cast_to<Node>(object);
+
+ Vector<SceneState::PackState> sstack;
+ if (node != nullptr) {
+ const Node *es = EditorNode::get_singleton()->get_edited_scene();
+ sstack = PropertyUtils::get_node_states_stack(node, es);
+ }
+
for (int i = 0; i < editors.size(); i++) {
EditorProperty *ep = Object::cast_to<EditorProperty>(editors[i].property_editor);
const Vector<String> &properties = editors[i].properties;
@@ -3453,7 +3461,15 @@ void EditorInspector::update_tree() {
ep->set_checked(checked);
ep->set_keying(keying);
ep->set_read_only(property_read_only || all_read_only);
- ep->set_deletable(deletable_properties || p.name.begins_with("metadata/"));
+ if (p.name.begins_with("metadata/")) {
+ Variant _default = Variant();
+ if (node != nullptr) {
+ _default = PropertyUtils::get_property_default_value(node, p.name, nullptr, &sstack, false, nullptr, nullptr);
+ }
+ ep->set_deletable(_default == Variant());
+ } else {
+ ep->set_deletable(deletable_properties);
+ }
}
current_vbox->add_child(editors[i].property_editor);