PersistentVariablesSource
Provides 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.
Read time 2 minutesLast updated 6 days ago
Definition
- Type: Class
- Namespace: Unity.SmartStrings.Extensions
- Assembly: UnityEngine.SmartStringsModule
- Implements: ISource, IDictionary<string, VariablesGroupAsset>, ICollection<KeyValuePair<string, VariablesGroupAsset>>, IEnumerable<KeyValuePair<string, VariablesGroupAsset>>, IEnumerable, ISerializationCallbackReceiver
public class PersistentVariablesSource : ISource, IDictionary<string, VariablesGroupAsset>, ICollection<KeyValuePair<string, VariablesGroupAsset>>, IEnumerable<KeyValuePair<string, VariablesGroupAsset>>, IEnumerable, ISerializationCallbackReceiver
Properties
Property | Description |
|---|---|
| Count | The number of VariablesGroupAsset that are used for global variables. |
| IsReadOnly | Implemented as part of IDictionary but not used. Always returns |
| this[] | The global variable group that matches |
| Keys | The global variable group names. |
| Values | The global variable groups in this source. |
Static Properties
Property | Description |
|---|---|
| IsUpdating | Whether PersistentVariablesSource.BeginUpdating has been called without a matching PersistentVariablesSource.EndUpdating. 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. |
Methods
Method | Description |
|---|---|
| Add | Adds a global variable group to the source. |
| Clear | Removes all global variables. |
| ContainsKey | Returns |
| CopyTo | Copies all global variable groups into the provided array starting at |
| GetEnumerator | Returns an enumerator for all the global variables in the source. |
| Remove | Removes the group with the matching name. |
| TryGetValue | Returns |
Static Methods
Method | Description |
|---|---|
| BeginUpdating | Indicates that multiple IVariable will be changed and localized string should wait for PersistentVariablesSource.EndUpdate before updating. See PersistentVariablesSource.EndUpdating and PersistentVariablesSource.EndUpdate. Note: PersistentVariablesSource.BeginUpdating and PersistentVariablesSource.EndUpdating can be nested, PersistentVariablesSource.EndUpdate will only be called after the last PersistentVariablesSource.EndUpdating. |
| EndUpdating | Indicates that updates to IVariable have finished and sends the PersistentVariablesSource.EndUpdate event. Note: PersistentVariablesSource.BeginUpdating and PersistentVariablesSource.EndUpdating can be nested, PersistentVariablesSource.EndUpdate will only be called after the last PersistentVariablesSource.EndUpdating. |
| UpdateScope | Creates a PersistentVariablesSource.BeginUpdating and PersistentVariablesSource.EndUpdating scope. |
Static Events
Member | Description |
|---|---|
| EndUpdate | Raised after the final PersistentVariablesSource.EndUpdating call. 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. |
Structs
Struct | Description |
|---|---|
| PersistentVariablesSource.ScopedUpdate | Encapsulates a PersistentVariablesSource.BeginUpdating and PersistentVariablesSource.EndUpdating call. |