Workshop

The Steam Workshop is designed as a place for your fans and community members to participate in the creation of content for your game. The form of this creation by community members can vary depending on the nature of the game and what kind of control you wish to have over the content in your game.

There are steps you need to take in the Steam Developer Portal to enable Steam Workshop for your game. Be sure you have read Valve's implementation guide and followed its instructions.

The following is a snip-it from the above-linked document. Be sure you do read the original document first; this is here as a quick reference only.

Enabling UGC for a Game or Application

Before workshop items can be uploaded to the Steamworks backend, two configuration settings must be made: Configuring Steam Cloud Quotas and Enabling the UGC API. The Steam Cloud feature is used to store the preview images associated with workshop items. The Steam Cloud Quota can be configured with the following steps:

  1. Navigate to the Steam Cloud Settings page in the App Admin panel.

  2. Set the Byte quota per user and the Number of files allowed per user to appropriate values for preview image storage

  3. Click Save

  4. From the Publish tab, click Prepare for Publishing

  5. Click Publish to Steam and complete the process to publish the change.

Enabling the UGC API can be accomplished with the following steps:

  1. You can just navigate to the Steam Workshop Configuration page in the App Admin panel.

  2. Find the Additional Configuration Options section.

  3. Check Enable ISteamUGC for file transfer.

  4. Click Save.

  5. From the Publish tab, click Prepare for Publishing.

  6. Click Publish to Steam and complete the process to publish the change.

Once these settings are in place, workshop content can be uploaded via the API.

Working with UGC

The process of uploading content to UGC is a simple 2-step process.

Create an Item

Using our tools, you will create a new empty item; this will provide you with a Published File handle that can be used in the second step.

Updating an Item

This process lets you update an existing Published File. You do this by calling "Start Update", which provides you with an update handle. You can then set each field of the item, such as Name, Description, Preview Image, and so on, and finalise the update with Submit item update.

Examples

Create Item

Code Free

You can use the Workshop Item Editor to power in-game Workshop tools..

The base editor defines the minimal required fields which can be connected to Input Fields for user or code-based population.

Add the Create & Update settings to expand with optional data, use the Create New or Create and Update functions to submit the item to Steam.

Add the Events settings to expose key events to help drive your editor UI

C#

// Use the Workshop Item Editor Data to build up your item
WorkshopItemEditorData data = new();
data.title = "New Item";
data.description = "My first workshop item";
data.content = new("C:\\MyModContent");
data.preview = new("C:\\MyModPreviewImage.png");
data.visibility = ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPrivate;

// Now you can create and update the item
// each callback is optional, but you should at least
// use HandleCompletion
data.Create(HandleCompletion, HandleUpdateStarted, HandleNewItemCreated);

public void HandleNewItemCreated(CreateItemResult createResult)
{
    // Invoked after the new file ID has been created, but before it
    // has had all its values set
}

public void HandleUpdateStarted(UGCUpdateHandle_t updateHandle)
{
    // Invoked when the update handle is created
    // This happens just before setting the title, description, etc.
}

public void HandleCompletion(WorkshopItemDataCreateStatus status)
{
    // Always invoked even if a failure occurred.
    // This will tell you the results of the create and update.
    // This is only invoked after all other steps are completed.
}

Update Item

Code Free

Use the Workshop Item Search to get the items that the player has published.

See the List Items example below..

You can use the Search My Published function to get all of the items published by the player.

In the Workshop Item component in your Workshop Item Search template, add the Edit settings. Note that this will automatically add the Events settings

You can attach input fields for quick edits to modify the title, description, content folder, etc., or you can pass the item a Workshop Item Editor for a more robust set of features.

Running the Set Editor function will load this item into the editor's memory. Note that the preview image and content folder path can't be loaded, so you will need to make sure you set those values yourself via an input field or a file/folder browser.

C#

This works similarly to Create Item as defined above, with 1 minor difference ... call Update instead of Create.

// Use the Workshop Item Editor Data to build up your item
WorkshopItemEditorData data = new();
data.title = "New Item";
data.description = "My first workshop item";
data.content = new("C:\\MyModContent");
data.preview = new("C:\\MyModPreviewImage.png");

// Call update when ready
data.Update(HandleCompleted, HandleUpdateStarted);

List Items

Code Free

Use the Workshop Item Search component to search for workshop items

The key and only "required" features are:

Template

This is the object that will be spawned for each item returned by your search. This would be a Unity UI prefab that has a Workshop Item component on it, helping you "display" each of the items.

Content

This is where each item will be parented when it's spawned. Typically, you would apply a "Layout" component to this, such as Unity's built-in Grid Layout component.

Setting up the Workshop Item

The Workshop Item component is what you attach to your "Template" to connect data from the workshop item to your UI elements.

This is a modular component, so you can add as much or as little functionality as you need for your UI.

We have a prefab called "Workshop Item Search" that demonstrates this complete system, and that prefab is used in our sample scene. Consult the installation guide for more information on how to find the prefabs and samples.

When you're ready to run the search, use a Unity Button or similar and call one of the "Search" functions.

Options include:

  • Search All Returns any item found, similar to browsing in the Workshop page on Steam

  • Search Favorites Returns only items the player has favourited

  • Search My Published Returns only items the player has created

  • Search Subscribed Returns only items the player has subscribed to, e.g. "installed"

C#

// Create a query to find the desired items
var query = UgcQuery.Get(EUGCQuery.k_EUGCQuery_RankedByTrend
    , EUGCMatchingUGCType.k_EUGCMatchingUGCType_Items_ReadyToUse
    , AppData.Me
    , AppData.Me);
    
// Optionally filter on a search string
query.SetSearchText("Text to search");

// Run the query
query.Execute(HandleResults);

// Handle the results
void HandleResults(UgcQuery query)
{
    // Iterate over the found items
    foreach (var result in query.ResultsList)
    {
        // Do something with it
    }
}

Find Installed Content

Code Free

You can find the items the player has installed by using the "Search Subscribed" option when listing items. Accessing the content it downloaded however will require C# code and is up to your programmer to do.

C#

// Get a query for the subscribed items
var query = UgcQuery.GetSubscribed();
// Run the query
query.Execute(HandleResults);

// Handle the results
void HandleResults(UgcQuery query)
{
    // Iterate over the found items
    foreach (var result in query.ResultsList)
    {
        // Check if its installed and download if needed
        if (!result.IsInstalled)
            result.DownloadItem(true);
        
        // Check if this item is downloading or going to download
        if (result.IsDownloading
           || result.IsDownloadPending)
            ;// handle download in progress

        // Monitor how much is downloaded
        float percentComplete = result.DownloadCompletion;

        // The location where the content is downloaded to
        result.FolderPath
    }
}

Last updated