Knowledge Base
HomeProductsCommunityReviewsSocial
Toolkit for Steamworks
Toolkit for Steamworks
  • Welcome
  • Register with Valve
  • Install
    • Unity Install
    • Unreal Install
  • Configuration
    • Unity Configuration
    • Unreal Configuration
  • Initialization
    • Unity Initialization
    • Unreal Initialization
  • Multiplayer
    • Unity Multiplayer
    • Unreal Multiplayer
  • Build Testing
  • Deploy
  • Launch
  • Features
    • Achievements
      • Unity Achievement Tools
    • Branches
    • Community Hub
    • Cloud Save
    • CSteamID
    • Discovery Queue
    • Downloadable Content
    • Early Access
    • Friends
    • Input
    • Inventory
    • Leaderboards
    • Lobby
      • Unity Lobby Tools
    • Overlay
    • Party
    • Playtest
    • Remote Play
    • Reviews
    • Rich Presence
    • Stats
    • Steam Game Server
    • Store Page
    • Workshop
    • Voice
Powered by GitBook
On this page
  • Pure Code
  • Namespace
  • Client
  • Server
  • Events
  • Debugging
  • Object
  • Configure Settings
  • Updating your Bootstrap
  • Component
  1. Initialization

Unity Initialization

PreviousInitializationNextUnreal Initialization

Last updated 29 days ago

Legacy worked a bit differently for Initialization ... see for more info

1st and foremost ... if you have SteamManager.cs in your project, remove it.

That script should not be used at all; it is not part of Heathen's Toolkit, and it was not meant to be dragged and dropped into a production project in the first place.

Cover

Code Free

  • Set your desired settings

  • Add component to game object

  • Done!

Cover

With Configuraiton

  • Doesn't require a GameObject

  • Single line of code

Cover

Pure Code

  • Doesn't require a GameObject

  • No ScriptableObject

  • Pure C#

Pure Code

You do NOT require any GameObjects to make Steamworks run. You can simply call our App API extension to initialize as a Client or Server, and our system will handle the rest for you, including running callbacks and updating input when and where required.

Namespace

using Heathen.SteamworksIntegration.API;

Client

Replace 480 with your app ID

App.Client.Initialize(480);

Optionally you can pass in additional data about your set-up, however, this is not usually done unless you are using Steam Settings objects in which case you can use them to initialize directly, see the Object section below.

Server

App.Client.Initialize(480, ServerConfig);

The server configuration is a structure where you can define the ports and settings you want Steamworks to use with your Steam Game Server.

Events

Regardless of which you're initialising for you can use bools and events to understand the results.

App.evtSteamInitialized.AddListener(HandleInitialized);
App.evtSteamInitializationError.AddListener(HanldeInitalizationError);

The handlers for these look like such

void HandleInitialized()
{
    Debug.Log("Success, Steam is ready to use");
}

void HanldeInitalizationError(string message)
{
    Debug.LogError("Failure, Steam reported error: " + message);
}

And for a bool check, you can simply do

if(App.Initialized)
{
    Debug.Log("Steamworks is ready to use");
}
else
{
    Debug.LogWarning("Steamworks is not yet initalized");
}

Debugging

To enable debugging from code, you can set the isDebugging value

App.isDebugging = true;

This will cause it to be more verbose about things. In general, you would set this before you initialise, so you can get more verbose initialisation steps as well.

Object

When you configured your Steam Settings, it created SteamSettings Objects that can be used to initialize directly. The Initialization function on these objects will read all required data from them and will select Client or Game Server based on the build type.

Configure Settings

Open your Project Settings and select Player > Steamworks

When you first do this it will create a SteamMain Steam Settings object in your project's Settings folder.

You can optionally add a Demo setting and as many Playtest settings as you would like. All of them will be added to the Settings folder in their own Steam Settings object.

Updating your Bootstrap

To do this, in a script that loads first in your game, ideally where you're performing bootstrap and validation logic, simply add a variable for Steam Settings, and then drag and drop the Steam Settings you would like to use.

Add a using statement

using Heathen.SteamworksIntegration;

Add a variable of type Steam Settings

[SerializeField]
private SteamSettings settings;

At an appropriate point in your bootstrap logic, call Initialize

settings.Initialize();

Component

If you need a code-free solution, we provide you with a component script Initialize Steamworks which will initialize the Steamworks SDK for you based on your configured Steam Settings.

This component should be put on your first scene, you should make sure Steamworks has initiated before you make any use of it and ideally, before you load it into your main menu.

You DO NOT need to mark this component as Do Not Destroy on Load ... it does not need to persist between levels and only exists to call Initialize on the settings you chose.

Legacy Getting Started