游戏上架Steam必须要接入SteamSDK,本篇文章简单介绍一下在UE4中接入SteamSDK的方法,后续与接入Steam平台服务相关的内容也会放到这篇文章中。
SteamSDK的接入可以使游戏与Steam的社区整合,Steam拥有很好的社区生态,这一点是Epic刚出的Epic Games Store目前比不了的~(当然我是支持市场竞争的。
废话不多说,首先,检查引擎目录下:
1
| Engine\Binaries\ThirdParty\Steamworks\Steamv139
|
该目录下是否有Win32
/Win64
文件夹,以及其中是否具有以下几个文件:
1
| steam_api.dll steamclient.dll tier0_s.dll vstdlib_s.dll
|
如果没有可以从Steam的安装目录拷贝过来。
之后打开项目,打开Plugins
- Online Platfrom
,确保启用以下三个插件:
- Online Subsystem NULL
- Online Subsystem Steam
- Online Subsystem Utils
打开项目的*.target.cs
文件,加入bUsesSteam = true;
:
1 2 3 4 5 6 7 8 9 10 11 12
| using UnrealBuildTool; using System.Collections.Generic;
public class SanguoWarriorsTarget : TargetRules { public SanguoWarriorsTarget(TargetInfo Target) : base(Target) { Type = TargetType.Game; bUsesSteam = true; ExtraModuleNames.AddRange( new string[] { "SanguoWarriors" } ); } }
|
打开项目的*.build.cs
,额外添加OnlineSubsystem的模块依赖:
1 2 3 4 5 6 7 8 9 10 11
| PublicDependencyModuleNames.AddRange( new string[] { "OnlineSubsystem", "OnlineSubsystemUtils", });
PrivateDependencyModuleNames.AddRange( new string[] { "OnlineSubsystem", "OnlineSubsystemUtils" });
|
打开项目目录下的Config/DefaultEngine.ini
,加入(或编辑)以下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13
| [/Script/Engine.Engine] !NetDriverDefinitions=ClearArray +NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")
[OnlineSubsystem] DefaultPlatformService=Steam PollingIntervalInMs=20
[OnlineSubsystemSteam] bEnabled=true SteamDevAppId=480 GameServerQueryPort=27015 bRelaunchInSteam=false
|
注意修改SteamDevAppId项为你自己的Steam内容的AppID.
上面的操作完毕之后,打开Steam(必须启动Steam才可以在游戏中使用Shift+Tab
)唤出Steam的界面。
然后可以使用Standalone
模式运行游戏,进入游戏后按下Shift+Tab
如果可以唤出Steam,即为成功。
如果日志中出现这样的警告:
1 2 3 4 5 6 7 8 9 10 11 12
| [2019.03.18-06.02.22:971][186]LogOnline: Warning: STEAM: Steamworks: SteamUtils() failed! [2019.03.18-06.02.22:971][186]LogOnline: Warning: STEAM: Steamworks: SteamUser() failed! [2019.03.18-06.02.22:972][186]LogOnline: Warning: STEAM: Steamworks: SteamFriends() failed! [2019.03.18-06.02.22:972][186]LogOnline: Warning: STEAM: Steamworks: SteamRemoteStorage() failed! [2019.03.18-06.02.22:973][186]LogOnline: Warning: STEAM: Steamworks: SteamUserStats() failed! [2019.03.18-06.02.22:973][186]LogOnline: Warning: STEAM: Steamworks: SteamMatchmakingServers() failed! [2019.03.18-06.02.22:973][186]LogOnline: Warning: STEAM: Steamworks: SteamApps() failed! [2019.03.18-06.02.22:973][186]LogOnline: Warning: STEAM: Steamworks: SteamNetworking() failed! [2019.03.18-06.02.22:974][186]LogOnline: Warning: STEAM: Steamworks: SteamMatchmaking() failed! [2019.03.18-06.02.22:974][186]LogOnline: Display: STEAM: OnlineSubsystemSteam::Shutdown() [2019.03.18-06.02.22:975][186]LogOnline: Warning: STEAM: Steam API failed to initialize! [2019.03.18-06.02.22:975][186]LogOnline: Display: STEAM: OnlineSubsystemSteam::Shutdown()
|
这是因为启动游戏时,没有打开Steam,先启动Steam再启动游戏即可。
打包需要注意的事情:
使用Shipping模式打包,打包完成后在打包输出的$ProjectName\Binaries\Win64下新建文件steam_appid.txt,将你的AppID填入其中即可(如480(Steam的测试AppID))。
外部资料