Steam

Configure Steam in LootLocker

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

LootLocker Steam Settings

Steam App ID

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

The App ID is behind the red square

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 values from the SteamWorks API.

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

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 adding SteamWorks integration in your project you can go ahead and authenticate the player. If successful, 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.

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.

Creating empty GameObject

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

Create new script on GameObject

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
{
    // Consider offsetting this from the start method to avoid startup race conditions
    void Start()
    {
        // To make sure Steamworks.NET is initialized
       if (!SteamManager.Initialized)
        {
            return;
        }
        
        var ticket = new byte[1024];
        var networkIdentity = new SteamNetworkingIdentity();
        HAuthTicket ticketResult = SteamUser.GetAuthSessionTicket(ticket, ticket.Length, out uint actualTicketSize, ref networkIdentity);
        if (ticket.Equals(HAuthTicket.Invalid))
        {
            Debug.LogWarning("Ticket from Steam was invalid: " + ticket.ToString());
            yield break;
        }

        LootLockerSDKManager.VerifyPlayerAndStartSteamSession(ref ticket, actualTicketSize, (response) =>
        {
            if (!response.success)
            {
                Debug.Log("Error starting a LootLocker session from the Steam User: " + response.errorData.ToString());
                return;
            }
            
            Debug.Log("Successfully started a LootLocker session from Steam User with ID: " + SteamID.ToString());
        });
}

Last updated