Holds the metadata items attached to a single localization target.
A collection is present on entries, shared keys, tables, and the shared data, so authors can attach comments and custom
properties (for example excluding an entry from export). Items are stored by reference, so any IMetadata
implementation keeps its own serialized fields. Query items by type with MetadataCollection.GetMetadata,
MetadataCollection.GetMetadatas, and MetadataCollection.Contains, and change the contents with
MetadataCollection.AddMetadata and MetadataCollection.RemoveMetadata.
Additional resources: IMetadata, Comment, ExcludeEntryFromEditorExport, SharedTableData
<para>Add a comment to a collection, then read it back by type.</para>
using Unity.Localization; using UnityEngine;
namespace Unity.Localization.Samples { public class MetadataCollectionOverviewExample { public void Run() { var metadata = new MetadataCollection(); metadata.AddMetadata(new Comment { CommentText = "Shown on the main menu." });
if (metadata.Contains<Comment>()) Debug.Log(metadata.GetMetadata<Comment>().CommentText); } } }
| Property | Description |
|---|---|
| Entries | The metadata items in this collection. |
| HasData | Whether any metadata is present. |
| Method | Description |
|---|---|
| AddMetadata | Adds a metadata item to the collection. |
| Contains | Checks whether a metadata item of the given type is present. |
| GetMetadata | Returns the first metadata item of the given type. |
| GetMetadatas | Enumerates every metadata item of the given type. |
| RemoveMetadata | Removes a specific metadata item from the collection. |