docs.unity3d.com
    目次を表示する/隠す

    Interface IMetadataVariable

    Adds support for querying the Metadata in a Smart String.

    Inherited Members
    IVariable.GetSourceValue(ISelectorInfo)
    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
    トップに戻る
    Copyright © 2023 Unity Technologies — 商標と利用規約
    • 法律関連
    • プライバシーポリシー
    • クッキー
    • 私の個人情報を販売または共有しない
    • Your Privacy Choices (Cookie Settings)