Unity (C#) SDK — Steam

Steam Integration

Mint Steam auth tickets client-side — the input for RegisterPlayerWithSteam

Setup

The Michitai.Multiplayer.Steam classes load the Steamworks flat API directly — no Steamworks.NET or Facepunch package needed. Required files:

  • steam_api64.dll from the Steamworks SDK redistributable_bin/win64 → Assets/Plugins/x86_64/ (x86 builds: steam_api.dll → Assets/Plugins/x86/)
  • steam_appid.txt at the project root and beside the built exe — just the AppID as text (480/Spacewar for development)
  • Steam client installed and logged in; otherwise SteamTicket.Initialize() returns false

Callbacks are pumped automatically: SteamBehaviour self-creates before the first scene and calls RunFrame() per Update plus Shutdown() on quit.

SteamTicket

public static class SteamTicket
{
    static bool Available { get; }                // SteamAPI_InitFlat succeeded
    static ulong SteamId { get; }                 // SteamID64, 0 when unavailable
    static string PersonaName { get; }
    static int InitResult { get; }                // ESteamAPIInitResult, -1 when never attempted
    static string InitError { get; }              // why init failed, or null
    static bool Initialize();                     // idempotent; false = no Steam client
    static Task<SteamAuthTicket> GetAuthTicketAsync(
        string identity = "michitai",
        CancellationToken ct = default);
    static void RunFrame();                       // per-frame pump (SteamBehaviour calls it)
    static void Shutdown();
}

SteamFriends

public static class SteamFriends
{
    static bool Available { get; }                     // SteamTicket.Available
    static List<SteamFriend> GetFriends(bool includeAll = false);
    static bool SetRichPresence(string key, string value);
    static string GetFriendRichPresence(ulong steamId, string key);
    static bool SetJoinConnectString(string connect);  // rich presence "connect"
    static void ClearJoinConnectString();
    static void OpenInviteDialog(string connectString);// overlay invite picker
    static void OpenOverlay(string dialog = "friends");
    static void OpenFriendProfile(ulong steamId);
    static void SetPlayedWith(ulong steamId);
    static string GetLaunchConnectString(string[] args = null); // "+connect" param
}
// Accept side — on SteamTicket:
static event Action<ulong, string> SteamTicket.RichPresenceJoinRequested;

Friend list, persona states, rich presence and the overlay invite dialog — all backed by the same Steamworks flat bindings, no extra packages.

Login flow

using Michitai.Multiplayer.Steam;

if (!SteamTicket.Initialize())
    goto offline; // no Steam client — game decides the offline policy

using (var ticket = await SteamTicket.GetAuthTicketAsync("michitai"))
{
    var reg = await Players.RegisterPlayerWithSteam<PlayerData>(
        client, ticket.Hex, "michitai", SteamTicket.PersonaName);
    playerToken = reg.private_key;
} // Dispose cancels the ticket handle — always dispose

Ticket rules:

  • Tickets are single-use — request a fresh one per login, never cache or retry
  • The identity string must match the server's steam_identity — keep "michitai"
  • Always Dispose the ticket (CancelAuthTicket) — handles leak Steam-side quota otherwise