Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

EntriesThe metadata items in this collection.
HasDataWhether any metadata is present.

Methods

Method

Description

AddMetadataAdds a metadata item to the collection.
ContainsChecks whether a metadata item of the given type is present.
GetMetadataReturns the first metadata item of the given type.
GetMetadatasEnumerates every metadata item of the given type.
RemoveMetadataRemoves a specific metadata item from the collection.