Online Subsystem Steam

本页面的内容:

Information contained here pertains specifically to the Steam implementation. Any additional setup steps, tips & tricks, and workarounds can be found here.

The Steam module implements most of the interfaces exposed through the online subsystem and supports most of what Valve offers through the Steamworks SDK.

Steam Interfaces

All games must have a valid Steam App ID. During development, this App ID is exposed to the SDK via a file called steam_appid.txt which must reside in the same directory as the executable. The file is generated by Unreal Engine at launch and deleted during graceful shutdown of the engine. This makes it unnecessary to launch the game via the Steam client (although it must be running). The file should not be included in any Steam images.

In shipping builds, the engine will also check to make sure the logged in user is properly subscribed to the game and will shutdown the engine if not. This is but one way to help secure the game. Using Steam DRM (see the Steamworks SDK) should further protect the game from tampering.

Basic Setup

The Steam subsystem requires some additional setup through Valve. Contact Valve and use their documentation to make sure you are setup on their end before attempting to use Steam in the Unreal Engine.

Installing the Steamworks SDK

For legal reasons, using Steam requires downloading the latest SDK from Valve. Currently this is v1.29a, but any future update should be a straightforward change to the path name. See Steamworks.build.cs in the ThirdParty/Steamworks directory

Using Steam against the precompiled version of the engine should only require copying some of the DLLs from Valve's SDK into the appropriate places. If you intend to recompile the engine against the source, putting the SDK in the right place is required as well.

If you are compiling the entire engine, you will want to modify the following line in OnlineSubsystemSteam\Private\OnlineSubsystemSteamPrivatePCH.h

define STEAM_SDK_VER TEXT("Steamv130")

to make sure it references the new SDK directory location / version

INI Configuration

Turn on some settings in the game's DefaultEngine.ini.

The SteamDevAppId of 480 is Valve's test app id, shared by everyone. You will need your own app id eventually, but most features of Steam should work before then.

[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
DefaultPlatformService=Steam

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480

[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"

Module Setup

Make sure to include the Unreal Engine Steam module as part of your project. (see 虚幻引擎编译系统的目标文件 for additional help)

Adding the following should be enough to make sure that the Steam module is built along with your game. It goes inside the constructor of mygame.build.cs

DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");

Steam Overlay on Mac

Contrary to Windows, Steam Overlay on Mac requires game to be launched using Steam client. For this you first need to add the game to your library using "Add a Non-Steam Game to My Library" option from Steam's Games menu.