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

    Interface ISource

    Evaluates a selector.

    Namespace: UnityEngine.Localization.SmartFormat.Core.Extensions
    Syntax
    public interface ISource

    Methods

    TryEvaluateSelector(ISelectorInfo)

    Evaluates the ISelectorInfo based on the CurrentValue. If this extension cannot evaluate the Selector, returns False. Otherwise, sets the Result and returns true.

    Declaration
    bool TryEvaluateSelector(ISelectorInfo selectorInfo)
    Parameters
    Type Name Description
    ISelectorInfo selectorInfo
    Returns
    Type Description
    Boolean
    Examples

    The following example shows how to create a source that generates a random number. This could then be combined with a ChooseFormatter to produce different random responses.

    using UnityEngine;
    using UnityEngine.Localization.SmartFormat.Core.Extensions;
    
    [System.Serializable]
    public class RandomValueSource : ISource
    {
    public int min = 1;
    public int max = 5;
    
    public string selector = "random";
    
    public bool TryEvaluateSelector(ISelectorInfo selectorInfo)
    {
        if (selectorInfo.SelectorText != selector)
            return false;
    
        selectorInfo.Result = Random.Range(min, max);
        return true;
    }
    }
    トップに戻る
    Copyright © 2023 Unity Technologies — 商標と利用規約
    • 法律関連
    • プライバシーポリシー
    • クッキー
    • 私の個人情報を販売または共有しない
    • Your Privacy Choices (Cookie Settings)