MetadataCollection
Holds the metadata items attached to a single localization target.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Class
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
public class MetadataCollection
Remarks
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.
Add a comment to a collection, then read it back by type.
Examples
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); } }}
Properties
Property | Description |
|---|---|
| Entries | The metadata items in this collection. |
| HasData | Whether any metadata is present. |
Methods
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. |