Create UGC In-Game

In this How-to, we’ll go through the process of creating a UGC asset candidate, adding some information to it and promoting it to a UGC asset that can be viewed by all players in your game.

Prerequisites

Create an asset candidate

The first thing a user needs to do is to create an asset candidate, which is the “working state” of UGC in LootLocker.

// Name is required when creating an asset candidate
string name = "New Asset Candidate";

// The below additional variables are optional
Dictionary<string, string> kv_storage = new Dictionary<string, string>();
kv_storage.Add("key", "value"); // Optional
Dictionary<string, string> filters = new Dictionary<string, string>();
filters.Add("key", "value"); // Optional
Dictionary<string, string> data_entities = new Dictionary<string, string>();
filters.Add("data", "name"); // Optional
int context_id = -1; // Optional

string asset_candidate_id = "";
LootLockerSDKManager.CreatingAnAssetCandidate(name, kv_storage, filters, data_entities, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully created asset candidate with ID: " + response.asset_candidate_id);
        // Save the asset_candidate_id for future requests
        asset_candidate_id = response.asset_candidate_id;
    }
    else
    {
        Debug.Log("Error asset candidate");
    }
});

We need the asset_instance_id for future requests, wait for the request to be done and save the asset_candidate_id before calling the next request.

Working with the asset candidate

After the asset candidate has been created you have several ways of modifying it:

Delete the asset candidate

Add files to the asset candidate

Remove files from the Asset candidate

Update or add data to the asset candidate

When you are satisfied with the changes to the asset candidate, you simply call the UpdatingAnAssetCandidate() function again, and change the isCompleted bool to true and the asset candidate will then be promoted to a UGC asset to be viewed by all your players.

Conclusion

In this How-to, we’ve created a UGC asset candidate, added some information to it and promoted it to an asset. If UGC moderation is enabled in your game, the newly generated asset will show up in the UGC moderation tab in the web console for you to take action on, and otherwise it will be available instantly to all your players by using any of the ListAssets() functions. With UGC it can also be a good idea to add a way for players to report the created content.

Last updated