menu_bookDocumentation
Storage UGC - s&box Assets Documentation
Storage UGC
The Storage system manages user-generated content. Save games, player creations, and share to Steam Workshop.
Creating a New Entry
Create a storage entry:
CSHARP
var entry = await Storage.CreateEntryAsync( "save", "My Adventure" );
entry.Description = "Level 5, 100 coins";
entry.SetTag( "chapter", "forest" );
entry.SetThumbnail( screenshot );Entry Properties
- Title — Display name
- Description — Long description
- Tags — Key-value metadata
- Thumbnail — Preview image
- Type — Category ("save", "dupe", "map")
Working with Files
Each entry has its own filesystem:
CSHARP
var fs = entry.FileSystem;
// Write
await fs.WriteAllTextAsync( "player.json", data );
// Read
string data = await fs.ReadAllTextAsync( "player.json" );
// Check exists
if ( fs.FileExists( "screenshot.png" ) )
{
byte[] image = await fs.ReadAllBytesAsync( "screenshot.png" );
}Listing Entries
Query storage:
CSHARP
var saves = await Storage.GetEntriesAsync( "save" );
var recent = saves.OrderByDescending( s => s.Modified );Deleting Entries
CSHARP
entry.Delete(); // PermanentSteam Workshop
Publish entries:
CSHARP
await entry.PublishAsync();Query Workshop:
CSHARP
var query = new Storage.Query
{
TagsRequired = { "save" },
SearchText = "adventure",
SortOrder = Storage.SortOrder.RankedByVote
};
var result = await query.Run();Install from Workshop:
CSHARP
var installed = await Storage.InstallAsync( workshopId );
Was this helpful?