Skip to content

ISteamworksContext

This interface tells you whether the Steamworks SDK is ready to use. It checks whether the current build target supports the Steamworks SDK, and whether the app has initialized the Steamworks SDK and connected to the Steam client. It does not initialize or shut down the Steamworks SDK.

  • Interface: ISteamworksContext
  • Namespace: Hive.Axyl.Steamworks
  • Package: com.com2usplatform.hiveaxyl.steamworks

Retrieval

Create the implementation that matches the current build target with SteamworksContext.CreateDefault(). You do not register it in HiveBootstrap.Initialize or retrieve it with HiveCore.Resolve<T>().

You can create it before you call SteamAPI.Init(). You can keep using the created object as is until the app exits. On unsupported platforms, an implementation whose two properties are always false is returned.

static ISteamworksContext CreateDefault()

Supported platforms

Platform Support Description
Windows Supported The Steam client must be running.
macOS Supported The Steam client must be running.
Linux Not supported Steamworks SDK integration is not supported.
Android, iOS Not supported For how to log in with a Steam account on these platforms, see OSs other than Windows and macOS.

SteamworksContext.CreateDefault() returns an object without throwing an exception even on unsupported platforms, so you do not need to check the platform before you call it. Check whether the platform is supported with IsSupported.

Properties

Property Type Description
IsSupported bool true if the current build target can run the Steamworks SDK. It is true only in Windows and macOS builds.
IsInitialized bool true if the app has initialized the Steamworks SDK and the Steam client is running, so a connection is possible. On Windows and macOS, it is the result of SteamAPI.IsSteamRunning(); on other platforms, it is always false.

It is normal for IsInitialized to be false before the app calls SteamAPI.Init(), and a false value that appears while you are arranging the initialization order is not an error.

Call example

using Hive.Axyl.Steamworks;

ISteamworksContext steamworks = SteamworksContext.CreateDefault();

if (!steamworks.IsInitialized)
{
    // The platform is not supported, or the Steamworks SDK has not been initialized yet.
    // Hide the Steam login button or prompt the user to launch the Steam client.
    return;
}

// You can call the Steam login Add-on and the Steam payment Add-on.

Steamworks SDK lifecycle

This module does not call SteamAPI.Init(), SteamAPI.RunCallbacks(), or SteamAPI.Shutdown(). The app is responsible for all three calls.

  1. App start: Call SteamAPI.Init() once
  2. Every frame: Call SteamAPI.RunCallbacks()
  3. App exit: Call SteamAPI.Shutdown() once

If you do not call SteamAPI.RunCallbacks() every frame, Steamworks callbacks are not delivered, so tasks such as Steam authentication ticket requests and payment authorization callbacks do not receive responses.

For the initialization procedure and how to prepare steam_appid.txt during development, see Initialize Steamworks.

macOS post-build processing

The bundle identifier of steam_api.bundle provided by Steamworks.NET contains an underscore, so it does not pass App Store and TestFlight validation. After the macOS build finishes, this module changes that identifier to a value that passes validation. The app does not need to configure anything, and this post-processing runs before external code signing.