Work with Files In-Game
Retrieving Player Files
Retrieve All Player Files
Retrieve all files associated with the player.
LootLockerSDKManager.GetAllPlayerFiles((response) =>
{
if (response.success)
{
Debug.Log("Successfully retrieved player files: " + response.items.Length);
}
else
{
Debug.Log("Error retrieving player storage");
}
});
Retrieve All Public Files From Another Player
Retrieve all (public) files associated with another player.
int playerId = 1;
LootLockerSDKManager.GetAllPlayerFiles(playerId, (response) =>
{
if (response.success)
{
Debug.Log("Successfully retrieved player files: " + response.items.Length);
}
else
{
Debug.Log("Error retrieving player storage");
}
});
Retrieve Single Player File
Retrieve a specific player file.
int playerFileId = 1;
LootLockerSDKManager.GetPlayerFile(playerFileId, (response) =>
{
if (response.success)
{
Debug.Log("Successfully retrieved player file with id: " + response.id);
}
else
{
Debug.Log("Error retrieving player file");
}
});
Uploading Player Files
Upload a Private Player File From Path
Upload a (private) player file from the file's path.
LootLockerSDKManager.UploadPlayerFile("/path/to/file/save_game.zip", "save_game", response =>
{
if (response.success)
{
Debug.Log("Successfully uploaded player file, url: " + response.url);
}
else
{
Debug.Log("Error uploading player file");
}
});
Upload a Public Player File From Path
Upload a (public) player file from the file's path.
// You can also set this to false, if omitted it defaults to false
bool isPublic = true;
LootLockerSDKManager.UploadPlayerFile("/path/to/file/save_game.zip", "save_game", isPublic, response =>
{
if (response.success)
{
Debug.Log("Successfully uploaded player file, url: " + response.url);
}
else
{
Debug.Log("Error uploading player file");
}
});
Upload a Private Player File Using FileStream
Upload a (private) file using FileStream.
var file = File.Open("/path/to/file/save_game.zip"", FileMode.Open);
LootLockerSDKManager.UploadPlayerFile(file, "player_file", response =>
{
if (response.success)
{
Debug.Log("Successfully uploaded player file, url: " + response.url);
}
else
{
Debug.Log("Error uploading player file");
}
});
Upload a Public Player File Using FileStream
Upload a (public) file using FileStream.
var file = File.Open("/path/to/file/save_game.zip"", FileMode.Open);
// You can also set this to false, if omitted it defaults to false
bool isPublic = true;
LootLockerSDKManager.UploadPlayerFile(file, "player_file", isPublic, response =>
{
if (response.success)
{
Debug.Log("Successfully uploaded player file, url: " + response.url);
}
else
{
Debug.Log("Error uploading player file");
}
});
Upload a Private Player File Using Byte Array
Upload a (private) file using byte array.
var file = File.Open("/path/to/file/save_game.zip"", FileMode.Open);
var fileBytes = new byte[file.Length];
file.Read(fileBytes, 0, Convert.ToInt32(file.Length));
LootLockerSDKManager.UploadPlayerFile(fileBytes, "filename", "save_game", response =>
{
if (response.success)
{
Debug.Log("Successfully uploaded player file, url: " + response.url);
}
else
{
Debug.Log("Error uploading player file");
}
});
Upload a Public Player File Using Byte Array
Upload a (public) file using byte array.
var file = File.Open("/path/to/file/save_game.zip"", FileMode.Open);
var fileBytes = new byte[file.Length];
file.Read(fileBytes, 0, Convert.ToInt32(file.Length));
// You can also set this to false, if omitted it defaults to false
bool isPublic = true;
LootLockerSDKManager.UploadPlayerFile(fileBytes, "filename", "save_game", isPublic, response =>
{
if (response.success)
{
Debug.Log("Successfully uploaded player file, url: " + response.url);
}
else
{
Debug.Log("Error uploading player file");
}
});
Updating Player Files
Update a Player File from Path
Update a player file from the file's path.
// The ID of the file can be retrieved when creating the file
// or when listing all player files.
int playerFileID = 0;
LootLockerSDKManager.UpdatePlayerFile(playerFileID, "/path/to/file/save_game.zip", response =>
{
if (response.success)
{
Debug.Log("Successfully updated player file, url: " + response.url);
}
else
{
Debug.Log("Error updating player file");
}
});
Update a Player File Using Byte Array
Update a player file using byte array.
// The ID of the file can be retrieved when creating the file
// or when listing all player files.
int playerFileID = 0;
var file = File.Open("/path/to/file/save_game.zip"", FileMode.Open);
var fileBytes = new byte[file.Length];
file.Read(fileBytes, 0, Convert.ToInt32(file.Length));
LootLockerSDKManager.UpdatePlayerFile(playerFileID, fileBytes, response =>
{
if (response.success)
{
Debug.Log("Successfully updated player file, url: " + response.url);
}
else
{
Debug.Log("Error updating player file");
}
});
Update a Player File Using FileStream
Update a player file using FileStream.
// The ID of the file can be retrieved when creating the file
// or when listing all player files.
int playerFileID = 0;
var file = File.Open("/path/to/file/save_game.zip"", FileMode.Open);
LootLockerSDKManager.UpdatePlayerFile(playerFileID, file, response =>
{
if (response.success)
{
Debug.Log("Successfully updated player file, url: " + response.url);
}
else
{
Debug.Log("Error updating player file");
}
});
Deleting Player Files
Delete Player File
Delete a player file.
// The ID of the file can be retrieved when creating the file
// or when listing all player files.
int playerFileId = 1;
LootLockerSDKManager.DeletePlayerFile(playerFileId, response =>
{
if (response.success)
{
Debug.Log("Successfully deleted player file with id: " + playerFileId);
}
else
{
Debug.Log("Error deleting player file");
}
});
Last updated