Class PersistentVariablesSource
Can be used to provide global or local values that do not need to be passed in as arguments when formatting a string. The smart string should take the format {groupName.variableName}. e.g {global.player-score}. Note: The group name and variable names must not contain any spaces.
Namespace: UnityEngine.Localization.SmartFormat.Extensions
Assembly: Unity.Localization.dll
Syntax
[Serializable]
public class PersistentVariablesSource : ISource, ISerializationCallbackReceiver
Constructors
Name | Description |
---|---|
PersistentVariablesSource(SmartFormatter) | Creates a new instance and adds the "." operator to the parser. |
Properties
Name | Description |
---|---|
Count | The number of VariablesGroupAsset that are used for global variables. |
IsReadOnly | Implmented as part of IDictionary but not used. Will always return false. |
IsUpdating | Has BeginUpdating() been called? This can be used when updating the value of multiple IVariable in order to do a single update after the updates instead of 1 per change. |
this[string] | Returns the global variable group that matches |
Keys | Returns the global variable group names. |
Values | Returns the global variable groups for this source. |
Methods
Name | Description |
---|---|
Add(KeyValuePair<string, VariablesGroupAsset>) | Add a global variable group to the source. |
Add(string, VariablesGroupAsset) | Add a global variable group to the source. |
BeginUpdating() | Indicates that multiple IVariable will be changed and LocalizedString should wait for EndUpdate before updating. See EndUpdating() and EndUpdate. Note: BeginUpdating() and EndUpdating() can be nested, EndUpdate will only be called after the last EndUpdate. |
Clear() | Removes all global variables. |
Contains(KeyValuePair<string, VariablesGroupAsset>) | Returns true if a global variable group is found with the same name. |
ContainsKey(string) | Returns true if a global variable group is found with the same name. |
CopyTo(KeyValuePair<string, VariablesGroupAsset>[], int) | Copy all global variable groups into the provided array starting at |
EndUpdating() | Indicates that updates to IVariable have finished and sends the EndUpdate event. Note: BeginUpdating() and EndUpdating() can be nested, EndUpdate will only be called after the last EndUpdate. |
GetEnumerator() | Returns an enumerator for all the global variables in the source. |
Remove(KeyValuePair<string, VariablesGroupAsset>) | Removes the group with the matching name. |
Remove(string) | Removes the group with the matching name. |
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. |
TryGetValue(string, out VariablesGroupAsset) | Returns true if a global variable group could be found with a matching name, or false if one could not. |
UpdateScope() | Can be used to create a BeginUpdating() and EndUpdating() scope. |
Events
Name | Description |
---|---|
EndUpdate | Called after the final EndUpdating() has been called. This can be used when you wish to respond to value change events but wish to do a single update at the end instead of 1 per change. For example, if you wanted to change the value of multiple global variables that a smart string was using then changing each value would result in a new string being generated, by using begin and end the string generation can be deferred until the final change so that only 1 update is performed. |