Godot Engine – Multi-platform 2D and 3D game engine
Allow metadata names of Object type to support Unicode identifiers
mengwa113376c42d3cfaf
diff --git a/core/object/object.cpp b/core/object/object.cppindex fd367b25bc9..0333138b335 100644--- a/core/object/object.cpp+++ b/core/object/object.cpp@@ -1033,7 +1033,7 @@ void Object::set_meta(const StringName &p_name, const Variant &p_value) {if (E) {E->value = p_value;} else {- ERR_FAIL_COND_MSG(!p_name.string().is_valid_ascii_identifier(), vformat("Invalid metadata identifier: '%s'.", p_name));+ ERR_FAIL_COND_MSG(!p_name.string().is_valid_unicode_identifier(), vformat("Invalid metadata identifier: '%s'.", p_name));Variant *V = &metadata.insert(p_name, p_value)->value;const String &sname = p_name;diff --git a/doc/classes/Object.xml b/doc/classes/Object.xmlindex 6aa60fad3c8..36fd232d3ea 100644--- a/doc/classes/Object.xml+++ b/doc/classes/Object.xml@@ -645,7 +645,7 @@<param index="1" name="default" type="Variant" default="null" /><description>Returns the object's metadata value for the given entry [param name]. If the entry does not exist, returns [param default]. If [param default] is [code]null[/code], an error is also generated.- [b]Note:[/b] A metadata's name must be a valid identifier as per [method StringName.is_valid_identifier] method.+ [b]Note:[/b] A metadata's name must be a valid identifier as per [method StringName.is_valid_unicode_identifier] method.[b]Note:[/b] Metadata that has a name starting with an underscore ([code]_[/code]) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.</description></method>@@ -731,7 +731,7 @@<param index="0" name="name" type="StringName" /><description>Returns [code]true[/code] if a metadata entry is found with the given [param name]. See also [method get_meta], [method set_meta] and [method remove_meta].- [b]Note:[/b] A metadata's name must be a valid identifier as per [method StringName.is_valid_identifier] method.+ [b]Note:[/b] A metadata's name must be a valid identifier as per [method StringName.is_valid_unicode_identifier] method.[b]Note:[/b] Metadata that has a name starting with an underscore ([code]_[/code]) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.</description></method>@@ -860,7 +860,7 @@<param index="0" name="name" type="StringName" /><description>Removes the given entry [param name] from the object's metadata. See also [method has_meta], [method get_meta] and [method set_meta].- [b]Note:[/b] A metadata's name must be a valid identifier as per [method StringName.is_valid_identifier] method.+ [b]Note:[/b] A metadata's name must be a valid identifier as per [method StringName.is_valid_unicode_identifier] method.[b]Note:[/b] Metadata that has a name starting with an underscore ([code]_[/code]) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.</description></method>@@ -967,7 +967,7 @@<description>Adds or changes the entry [param name] inside the object's metadata. The metadata [param value] can be any [Variant], although some types cannot be serialized correctly.If [param value] is [code]null[/code], the entry is removed. This is the equivalent of using [method remove_meta]. See also [method has_meta] and [method get_meta].- [b]Note:[/b] A metadata's name must be a valid identifier as per [method StringName.is_valid_identifier] method.+ [b]Note:[/b] A metadata's name must be a valid identifier as per [method StringName.is_valid_unicode_identifier] method.[b]Note:[/b] Metadata that has a name starting with an underscore ([code]_[/code]) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.</description></method>diff --git a/editor/inspector/add_metadata_dialog.cpp b/editor/inspector/add_metadata_dialog.cppindex 1c16cec2e8d..bc6aae95857 100644--- a/editor/inspector/add_metadata_dialog.cpp+++ b/editor/inspector/add_metadata_dialog.cpp@@ -106,7 +106,7 @@ void AddMetadataDialog::_check_meta_name() {if (meta_name.is_empty()) {validation_panel->set_message(EditorValidationPanel::MSG_ID_DEFAULT, TTRC("Metadata name can't be empty."), EditorValidationPanel::MSG_ERROR);- } else if (!meta_name.is_valid_ascii_identifier()) {+ } else if (!meta_name.is_valid_unicode_identifier()) {validation_panel->set_message(EditorValidationPanel::MSG_ID_DEFAULT, TTRC("Metadata name must be a valid identifier."), EditorValidationPanel::MSG_ERROR);} else if (_existing_metas.find(meta_name)) {validation_panel->set_message(EditorValidationPanel::MSG_ID_DEFAULT, vformat(TTR("Metadata with name \"%s\" already exists."), meta_name), EditorValidationPanel::MSG_ERROR);