Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

MetadataCollection

class in Unity.Localization

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

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); } } }

Properties

Property Description
Entries The metadata items in this collection.
HasData Whether any metadata is present.

Public 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.