Facepunch.Steamworks 2.0.0

Another fucking c# Steamworks implementation

There is a newer version of this package available.
See the version list below for details.
Install-Package Facepunch.Steamworks -Version 2.0.0
dotnet add package Facepunch.Steamworks --version 2.0.0
<PackageReference Include="Facepunch.Steamworks" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Facepunch.Steamworks --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

If you're making a game you probably want the SteamClient. This gives access to things like friends, achievements, stats, server lists etc.

Dlls

You need to copy us to your project to be able to use Steamworks.

Regular .net app

You'll need to put steam_api64.dll somewhere - and make sure you're building as 64bit.

Unity

If you're using Unity, open the release zip file and copy the Unity file into your project, anywhere in Assets (we usually put it in Assets/Plugins/Facepunch.Steamworks/.

The zip file already includes .meta files so that files the dlls are set up properly. The .meta files for the native dlls are set up in a way that mean that they're used on the right platforms and will get copied properly on build. You don't need to do anything special.

Initializing

To start up you just call Steamworks.SteamClient.Init with your appid. If it can't initialize it'll throw an exception - so make sure you catch that and deal with it.

try
{
	Steamworks.SteamClient.Init( 252490 );
}
catch ( System.Exception e )
{
	// Something went wrong! Steam is closed?
}

Common reasons for exceptions are:

  • Steam is closed
  • Can't find steam_api dlls
  • Don't have permission to open appid

In Unity I'd recommend calling this in an Awake on an object with DontDestroyOnLoad called on it.

Running

Every frame or so you should call RunCallbacks.

Steamworks.SteamClient.RunCallbacks();

In Unity I'd recommend sticking it in an Update.

Using

You can make sure Steam is loaded and accessible using SteamClient.IsValid.

Here's some examples of other interfaces and functions to give you an idea of how to use/find stuff.

var playername = SteamClient.Name;
var playersteamid = SteamClient.SteamId;

SteamScreenshots.TriggerScreenshot();

Steamworks.SteamUserStats.SetStat( "deaths", value );

foreach ( var item in Steamworks.SteamInventory.Items )
{
	Debug.Log( $"{item.Def.Name} x {item.Quantity}" );
}

foreach ( var player in SteamFriends.GetFriends() )
{
	Debug.Log( $"{player.Name}" );
}

Shutting Down

When you're done call SteamClient.Shutdown.

Steamworks.SteamClient.Shutdown();

A word of warning: Steam won't actually show that you've stopped playing the game at this point. It doesn't do that until the exe and any child processes are closed. It sucks, but that's the way it is.

This also means that in the Unity Editor it'll show as in game until you close the editor, but subsequent SteamClient.Init calls are needed and will work.

In Unity I'd recommend sticking it in an OnDisable, so that it gets called every time you stop playing.

If you're making a game you probably want the SteamClient. This gives access to things like friends, achievements, stats, server lists etc.

Dlls

You need to copy us to your project to be able to use Steamworks.

Regular .net app

You'll need to put steam_api64.dll somewhere - and make sure you're building as 64bit.

Unity

If you're using Unity, open the release zip file and copy the Unity file into your project, anywhere in Assets (we usually put it in Assets/Plugins/Facepunch.Steamworks/.

The zip file already includes .meta files so that files the dlls are set up properly. The .meta files for the native dlls are set up in a way that mean that they're used on the right platforms and will get copied properly on build. You don't need to do anything special.

Initializing

To start up you just call Steamworks.SteamClient.Init with your appid. If it can't initialize it'll throw an exception - so make sure you catch that and deal with it.

try
{
	Steamworks.SteamClient.Init( 252490 );
}
catch ( System.Exception e )
{
	// Something went wrong! Steam is closed?
}

Common reasons for exceptions are:

  • Steam is closed
  • Can't find steam_api dlls
  • Don't have permission to open appid

In Unity I'd recommend calling this in an Awake on an object with DontDestroyOnLoad called on it.

Running

Every frame or so you should call RunCallbacks.

Steamworks.SteamClient.RunCallbacks();

In Unity I'd recommend sticking it in an Update.

Using

You can make sure Steam is loaded and accessible using SteamClient.IsValid.

Here's some examples of other interfaces and functions to give you an idea of how to use/find stuff.

var playername = SteamClient.Name;
var playersteamid = SteamClient.SteamId;

SteamScreenshots.TriggerScreenshot();

Steamworks.SteamUserStats.SetStat( "deaths", value );

foreach ( var item in Steamworks.SteamInventory.Items )
{
	Debug.Log( $"{item.Def.Name} x {item.Quantity}" );
}

foreach ( var player in SteamFriends.GetFriends() )
{
	Debug.Log( $"{player.Name}" );
}

Shutting Down

When you're done call SteamClient.Shutdown.

Steamworks.SteamClient.Shutdown();

A word of warning: Steam won't actually show that you've stopped playing the game at this point. It doesn't do that until the exe and any child processes are closed. It sucks, but that's the way it is.

This also means that in the Unity Editor it'll show as in game until you close the editor, but subsequent SteamClient.Init calls are needed and will work.

In Unity I'd recommend sticking it in an OnDisable, so that it gets called every time you stop playing.

  • .NETFramework 4.6

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Facepunch.Steamworks:

Repository Stars
egordorichev/BurningKnight
C# branch of BK

Version History

Version Downloads Last updated
2.3.3 1,644 2/28/2020
2.3.1 145 2/25/2020
2.3.0 173 2/24/2020
2.2.0 896 8/29/2019
2.1.0 473 6/21/2019
2.0.0 231 5/30/2019
0.7.5 1,081 3/21/2018
Show less