Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

public class PersistentVariablesSource : ISource, IDictionary<string, VariablesGroupAsset>, ICollection<KeyValuePair<string, VariablesGroupAsset>>, IEnumerable<KeyValuePair<string, VariablesGroupAsset>>, IEnumerable, ISerializationCallbackReceiver

Properties

Property

Description

CountThe number of VariablesGroupAsset that are used for global variables.
IsReadOnlyImplemented as part of IDictionary but not used. Always returns
false
.
this[]The global variable group that matches
name
.
KeysThe global variable group names.
ValuesThe global variable groups in this source.

Static Properties

Property

Description

IsUpdatingWhether 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

AddAdds a global variable group to the source.
ClearRemoves all global variables.
ContainsKeyReturns
true
if a global variable group is found with the same name.
CopyToCopies all global variable groups into the provided array starting at
arrayIndex
.
GetEnumeratorReturns an enumerator for all the global variables in the source.
RemoveRemoves the group with the matching name.
TryGetValueReturns
true
if a global variable group could be found with a matching name, or
false
if one could not.

Static Methods

Static Events

Member

Description

EndUpdateRaised 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