Interface IMetadataVariable
Adds support for querying the Metadata in a Smart String.
Inherited Members
Namespace: UnityEngine.Localization.SmartFormat.PersistentVariables
Syntax
public interface IMetadataVariable : IVariable
Examples
In some languages, such as Spanish, all nouns have a gender, that means they are either masculine or feminine.
The structure of the sentence will change according to the gender of the item.
This example shows how metadata can be used to mark an entry with a gender which can
then be queried to create a dynamic string with the correct gender forms.
This shows how the following metadata could be used in a Smart String, where item
is a LocalizedString local variable:
{item.gender:choose(Male|Female):El|La}
[Metadata(AllowedTypes = MetadataType.StringTableEntry)]
[Serializable]
public class ItemGender : IMetadata, IMetadataVariable
{
public enum Gender
{
None,
Female,
Male
}
public Gender gender = Gender.None;
/// <summary>
/// The name used to identify this metadata.
/// </summary>
public string VariableName => "gender";
public object GetSourceValue(ISelectorInfo _) => gender;
}
Properties
VariableName
The named placeholder that will match this metdata when querying a LocalizedString as a local or global variable.
Declaration
string VariableName { get; }
Property Value
Type | Description |
---|---|
String |