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