SetVariable

Method

Set the value of a variable at the given key.

Remarks

The key can be a / separated path to set the value in a nested dictionary. For example, the key "player/inventory/loot" will set the variable found at dataStore["player"]["inventory"]["loot"].

Definition

DataStoreOperationRequest SetVariable(string key, object value)
DataStoreOperationRequest SetVariable(string key, object value)

Returns DataStoreOperationRequest

Parameters

ParameterDescription
string key
object value

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