docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method TryEvaluateSelector

    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
    bool
    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;
        }
    }
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)