MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / set_meta

Method set_meta

core/object/object.cpp:1060–1088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1058}
1059
1060void Object::set_meta(const StringName &p_name, const Variant &p_value) {
1061 if (p_value.get_type() == Variant::NIL) {
1062 if (metadata.has(p_name)) {
1063 metadata.erase(p_name);
1064
1065 const String &sname = p_name;
1066 metadata_properties.erase("metadata/" + sname);
1067 if (!sname.begins_with("_")) {
1068 // Metadata starting with _ don't show up in the inspector, so no need to update.
1069 notify_property_list_changed();
1070 }
1071 }
1072 return;
1073 }
1074
1075 HashMap<StringName, Variant>::Iterator E = metadata.find(p_name);
1076 if (E) {
1077 E->value = p_value;
1078 } else {
1079 ERR_FAIL_COND_MSG(!p_name.operator String().is_valid_ascii_identifier(), vformat("Invalid metadata identifier: '%s'.", p_name));
1080 Variant *V = &metadata.insert(p_name, p_value)->value;
1081
1082 const String &sname = p_name;
1083 metadata_properties["metadata/" + sname] = V;
1084 if (!sname.begins_with("_")) {
1085 notify_property_list_changed();
1086 }
1087 }
1088}
1089
1090Variant Object::get_meta(const StringName &p_name, const Variant &p_default) const {
1091 if (!metadata.has(p_name)) {

Callers 1

loadMethod · 0.45

Calls 9

vformatFunction · 0.85
begins_withMethod · 0.80
get_typeMethod · 0.45
hasMethod · 0.45
eraseMethod · 0.45
findMethod · 0.45
StringMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected