GetVariable

Method

Retrieves the value of a variable at the given key.

Remarks

The key can be a / separated path to search through dictionaries. For example, the key "player/inventory/loot" will return the variable found at dataStore["player"]["inventory"]["loot"].

Definition

DataStoreGetVariableRequest GetVariable(string key, object defaultValue)
DataStoreGetVariableRequest GetVariable(string key, object defaultValue)

Returns DataStoreGetVariableRequest

Parameters

ParameterDescription
string key
object defaultValue

Examples

public int playerHighScore = 0;

public void LoadHighScore()
{
SpatialBridge.userWorldDataStoreService.GetVariable("playerHighScore", 0).SetCompletedEvent((response) => {
//once the GetVariable request is completed this code will run.
playerHighScore = response.intValue;
Debug.Log("Player High Score: " + playerHighScore);
});
}

public void SaveHighScore()
{
SpatialBridge.userWorldDataStoreService.SetVariable("playerHighScore", playerHighScore);
}
public int playerHighScore = 0;

public void LoadHighScore()
{
SpatialBridge.userWorldDataStoreService.GetVariable("playerHighScore", 0).SetCompletedEvent((response) => {
//once the GetVariable request is completed this code will run.
playerHighScore = response.intValue;
Debug.Log("Player High Score: " + playerHighScore);
});
}

public void SaveHighScore()
{
SpatialBridge.userWorldDataStoreService.SetVariable("playerHighScore", playerHighScore);
}