Steamworks Behaviour
The most important part
Like what your seeing?
Support us as a GitHub Sponsor and get instant access to all our assets, exclusive tools and assets, escalated support and issue tracking and our gratitude. These articles are made possible by our GitHub Sponsors ... become a sponsor today!
Introduction
Steamworks Behaviour simply initializes the Steam API for you and exposes common events to the Unity Inspector. As of version 2.30.12 Steamworks Behaviour no longer runs the callback loop. We have made it such that Steam API can be initialized and ran without using any component scripts. That said most uses cases will greatly benifit from using Steamworks Behaviour in their bootstrap scene.
Use
You should add a Steamworks Behaviour component to a game object in the first scene to be loaded by your game. It is important that this game object is never destroyed as it is operating your Steam API integration. We do recommend you use additive loading and simply never unload your bootstrapping scene however you can use the Do Not Destroy approach if you are carful to NEVER reload the scene that defined Steamworks Behaviour.
The Steamworks behaviour is not intended to be a functional component that is you will not interact with this component, it exists wholly to initialize, operate and shutdown the Steam API integration according to Unity events. The one exception to this case is when operating a Steam Game Server in a situation where you need to delay API initialization. You can optionally configure your Steam Settings to NOT auto initialize Steam Game Server, in which case you will need to call SteamworksBeahviour.InitializeGameServer in order to kick off the initialization process.
This is rare and in general you should be allowing the system to auto initialize.
Events
Evt Steam Initialized
This is invoked when Steam API is fully initialized and all artifacts are ready for use.
This event has no parameters, a handler for this event would like:
Evt Steam Initialization Error
This is invoked if the Steam API fails to initialize.
This event has 1 parameter of type string which is a message indicating why it failed to initialize. A handler for this event would look like:
Evt Lobby Invite Argument Detected
This is invoked after initialization completes if the system detects a lobby ID was passed in on the command line arguments. This occurs when a user accepted a lobby invite but was not currently playing the game. In that use case Steam will launch the game with the lobby ID on the command line.
This event has 1 argument of type Lobby, being the lobby that was passed in on the command line argument and would have a handler that looks like:
Fields and Attributes
Settings
The SteamSettings that should be used when initializing the API.
Methods
Create If Missing
A static method that can be used to create a Steamworks Behaviour safely on demand. It is not recommend to do this, you should be using a Bootstrap scene where the Steamworks Behaviour is set up at development time.
If you choose or simply must use a "late initialization" approach then this method can be used to safely create the Steamworks Behaviour and optionally mark it as Do Not Destroy. Note this will not create anything if a Steamworks Behaviour already exists.
Last updated