Skip to content

rkhadder/XboxLiveConnectedStorageSample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Connected Storage Sample

A sample that demostrates how to save and load data from connected storage

Initialize

XboxLiveUser user = SignInManager.Instance.GetPlayer(1);
GameSaveHelper gameSaveHelper = new GameSaveHelper();
StartCoroutine(gameSaveHelper.Initialize(user, result =>
{
    print(result == GameSaveStatus.Ok
            ? "Successfully initialized save system."
            : string.Format("InitializeSaveSystem failed: {0}", result));
}));

Save

if (gameSaveHelper.IsInitialized())
{
    var data = new Dictionary<string, byte[]>();
    data[BLOB_NAME] = System.Text.Encoding.Unicode.GetBytes(/* some value */);

    StartCoroutine(gameSaveHelper.SubmitUpdates(CONTAINER_NAME, data, null, result =>
    {
        print(result == GameSaveStatus.Ok
                ? "Successfully stored data."
                : string.Format("Couldn't store data: {0}", result));
    }));
}
else
{
    print("GameSaveHelper is not initialized");
}

Load

if (gameSaveHelper.IsInitialized())
{
    StartCoroutine(gameSaveHelper.GetAsBytes(CONTAINER_NAME, new string[] { BLOB_NAME }, result =>
    {
        if (result.ContainsKey(BLOB_NAME))
        {
            string value = System.Text.Encoding.Unicode.GetString(result[BLOB_NAME]);
        }
        else
        {
            print("Couldn't load data");
        }
    }));
}
else
{
    print("GameSaveHelper is not initialized");
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages