Steam

Authenticate your players using their active Steam session and register a session for them on the LootLocker backend.

To use Steam in your game you must be a registered developer and have a game with SteamWorks

Configure Steam in LootLocker

Go to Platform Settings in the LootLocker Web Console and make sure the Steam platform is enabled.

Steam App ID

To get the Steam App ID you have to log in to the SteamWorks Partner Dashboard.

Steam Publisher Key

To find the Steam Publisher Key you can follow this guide from Valve.

Install SteamWorks in Your Project

Before we can authenticate with Steam and start a LootLocker session we must have access to a few features from the SteamWorks API.

To learn more about authentication with Steam you can read their documentation for Session Tickets in SteamWorks.

Remember to set Steam as platform in the LootLocker SDK Settings in your Unity project.

Our recommended way to gain access to the SteamWorks API in a Unity Game is by using the 3rd party library called Steamworks.NET

Install Steamworks.NET using the instructions found here: http://steamworks.github.io/installation/

Authenticate Player

After installing SteamWorks in your project

We'll start by creating a new empty Game Object in your scene and calling it GameManager. Feel free to skip this if you already have a GameManager or similar in your game.

In this new GameObject you can add a new script called GameManager.

Open up your new script in your editor of choice and add the following code:

using LootLocker.Requests;
using Steamworks;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    void Start()
    {
        // To make sure Steamworks.NET is initialized
       if (!SteamManager.Initialized)
        {
            return;
        }
        
        var ticket = new byte[1024];
        var networkIdentity = new SteamNetworkingIdentity();
        var newTicket = SteamUser.GetAuthSessionTicket(ticket, 1024, out uint ticketSize, ref networkIdentity);
        string steamSessionTicket = LootLockerSDKManager.SteamSessionTicket(ref ticket, ticketSize);

        LootLockerSDKManager.VerifySteamID(steamSessionTicket, (response) =>
        {
            if (!response.success)
            {
                Debug.Log("Error verifying Steam ID: " + response.errorData.message);
                return;
            }
        });
}

You do not need to store the result of this call anywhere as LootLocker knows to expect a Game Session call within 5 minutes.

Register a Session

Now that we have successfully verified the Session Ticket with LootLocker, we are ready to register a Game Session. This call will return a lot of data that you can use to display to the Player or make more calls to LootLocker during this session.

You have 5 minutes to register a Game Session after a successful Player Verification response before starting over with a new Player Verification.

Add the following snippet to your GameManager after verifying the Steam user:

CSteamID SteamID = SteamUser.GetSteamID();
LootLockerSDKManager.StartSteamSession(SteamID.ToString(), (response) =>
{
    if (!response.success)
    {
        Debug.Log("error starting sessions");
        return;
    }

    Debug.Log("session started!");
});

For a combined snippet including verification and session start see this gist.

Congratulations - you have now started using LootLocker in your game with Steam! Next up we suggest you look at our feature set, and decide which ones you want to use in your game.

Last updated