独立游戏如何对接steamsdk

Mr.Gavin Mr.Gavin     2022-08-22     583

关键词:

独立开发者在对接STEAM SDK之前 首先得先登上青睐之光,也就是我们俗称的“绿光”

一般要先对接G胖家的SDK,然后提交版本,最后等待审核。。。

我本身是unity 开发,对C++也是糊里糊涂..所以这里主要围绕unity说下我对接SDK的一些经历 

 

 

sdk地址:http://steamworks.github.io/installation/

c#接口介绍地址:http://steamworks.github.io/gettingstarted/

steamwork使用教程视频:https://www.youtube.com/playlist?list=PLckFgM6dUP2jBeskIPG-7BVJR-I0vcSGJ

-----------------------------------------------------------------------------------------------------

第一步:

安装 Steamwork.NET(这里要感谢外国小哥)

1.下载 .unitypackage Stable (7.0.0) 或者从 Github 克隆

2.导入下载的所有文件到项目 Assets/ 目录下.

3.打开unity项目,会自动生成steam_appid.txt到项目的主目录下.

4.打开 steam_appid.txt 并将 480 修改为自己的 AppId.

5.更改脚本 SteamManager.cs 找到  SteamAPI.RestartAppIfNecessary(AppId_t.Invalid)将AppId_t.Invalid替换成(AppId_t)480" 或者 "new AppId_t(480),480改成自己的APP ID如图:

  1. if (SteamAPI.RestartAppIfNecessary(new AppId_t(55220))) {  
  2.     Application.Quit();  
  3.     return;  
  4. }  

6.Steam根据提示修改重启unity,保证 steam_appid.txt 已生效.

7.重启unity,保证 steam_appid.txt 已生效.

8.安装sdk完成.

 
 

如何使用

1.下载SteamManagers.cs

2.将SteamManager.cs脚本挂在GameObject上,steam会自动生成单例

3.完整C#接口请点击查看

 
注:需要在https://partner.steamgames.com/home下载sdk,里面有提交游戏的工具,在sdk oolsContentBuilderuilder
        在https://partner.steamgames.com/home/steamworks可以查看文档
        在http://steamworks.github.io/gettingstarted/可以查看C#接口的使用方式
 
完整SteamManager:
  1. // The SteamManager is designed to work with Steamworks.NET  
  2. // This file is released into the public domain.  
  3. // Where that dedication is not recognized you are granted a perpetual,  
  4. // irrevokable license to copy and modify this files as you see fit.  
  5. //  
  6. // Version: 1.0.5  
  7.   
  8. using UnityEngine;  
  9. using System.Collections;  
  10. using Steamworks;  
  11.   
  12. //  
  13. // The SteamManager provides a base implementation of Steamworks.NET on which you can build upon.  
  14. // It handles the basics of starting up and shutting down the SteamAPI for use.  
  15. //  
  16. [DisallowMultipleComponent]  
  17. public class SteamManager : MonoBehaviour {  
  18.     private static SteamManager s_instance;  
  19.     private static SteamManager Instance {  
  20.         get {  
  21.             if (s_instance == null) {  
  22.                 return new GameObject("SteamManager").AddComponent<SteamManager>();  
  23.             }  
  24.             else {  
  25.                 return s_instance;  
  26.             }  
  27.         }  
  28.     }  
  29.   
  30.     private static bool s_EverInialized;  
  31.   
  32.     private bool m_bInitialized;  
  33.     public static bool Initialized {  
  34.         get {  
  35.             return Instance.m_bInitialized;  
  36.         }  
  37.     }  
  38.   
  39.     private SteamAPIWarningMessageHook_t m_SteamAPIWarningMessageHook;  
  40.     private static void SteamAPIDebugTextHook(int nSeverity, System.Text.StringBuilder pchDebugText) {  
  41.         Debug.LogWarning(pchDebugText);  
  42.     }  
  43.   
  44.     private void Awake() {  
  45.         // Only one instance of SteamManager at a time!  
  46.         if (s_instance != null) {  
  47.             Destroy(gameObject);  
  48.             return;  
  49.         }  
  50.         s_instance = this;  
  51.   
  52.         if(s_EverInialized) {  
  53.             // This is almost always an error.  
  54.             // The most common case where this happens is when SteamManager gets destroyed because of Application.Quit(),  
  55.             // and then some Steamworks code in some other OnDestroy gets called afterwards, creating a new SteamManager.  
  56.             // You should never call Steamworks functions in OnDestroy, always prefer OnDisable if possible.  
  57.             throw new System.Exception("Tried to Initialize the SteamAPI twice in one session!");  
  58.         }  
  59.   
  60.         // We want our SteamManager Instance to persist across scenes.  
  61.         DontDestroyOnLoad(gameObject);  
  62.   
  63.         if (!Packsize.Test()) {  
  64.             Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this);  
  65.         }  
  66.   
  67.         if (!DllCheck.Test()) {  
  68.             Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this);  
  69.         }  
  70.   
  71.         try {  
  72.             // If Steam is not running or the game wasn‘t started through Steam, SteamAPI_RestartAppIfNecessary starts the  
  73.             // Steam client and also launches this game again if the User owns it. This can act as a rudimentary form of DRM.  
  74.   
  75.             // Once you get a Steam AppID assigned by Valve, you need to replace AppId_t.Invalid with it and  
  76.             // remove steam_appid.txt from the game depot. eg: "(AppId_t)480" or "new AppId_t(480)".  
  77.             // See the Valve documentation for more information: https://partner.steamgames.com/documentation/drm#FAQ  
  78.             if (SteamAPI.RestartAppIfNecessary(AppId_t.Invalid)) {  
  79.                 Application.Quit();  
  80.                 return;  
  81.             }  
  82.         }  
  83.         catch (System.DllNotFoundException e) { // We catch this exception here, as it will be the first occurence of it.  
  84.             Debug.LogError("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It‘s likely not in the correct location. Refer to the README for more details. " + e, this);  
  85.   
  86.             Application.Quit();  
  87.             return;  
  88.         }  
  89.   
  90.         // Initialize the SteamAPI, if Init() returns false this can happen for many reasons.  
  91.         // Some examples include:  
  92.         // Steam Client is not running.  
  93.         // Launching from outside of steam without a steam_appid.txt file in place.  
  94.         // Running under a different OS User or Access level (for example running "as administrator")  
  95.         // Ensure that you own a license for the AppId on your active Steam account  
  96.         // If your AppId is not completely set up. Either in Release State: Unavailable, or if it‘s missing default packages.  
  97.         // Valve‘s documentation for this is located here:  
  98.         // https://partner.steamgames.com/documentation/getting_started  
  99.         // https://partner.steamgames.com/documentation/example // Under: Common Build Problems  
  100.         // https://partner.steamgames.com/documentation/bootstrap_stats // At the very bottom  
  101.   
  102.         // If you‘re running into Init issues try running DbgView prior to launching to get the internal output from Steam.  
  103.         // http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx  
  104.         m_bInitialized = SteamAPI.Init();  
  105.         if (!m_bInitialized) {  
  106.             Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve‘s documentation or the comment above this line for more information.", this);  
  107.   
  108.             return;  
  109.         }  
  110.   
  111.         s_EverInialized = true;  
  112.     }  
  113.   
  114.     // This should only ever get called on first load and after an Assembly reload, You should never Disable the Steamworks Manager yourself.  
  115.     private void OnEnable() {  
  116.         if (s_instance == null) {  
  117.             s_instance = this;  
  118.         }  
  119.   
  120.         if (!m_bInitialized) {  
  121.             return;  
  122.         }  
  123.   
  124.         if (m_SteamAPIWarningMessageHook == null) {  
  125.             // Set up our callback to recieve warning messages from Steam.  
  126.             // You must launch with "-debug_steamapi" in the launch args to recieve warnings.  
  127.             m_SteamAPIWarningMessageHook = new SteamAPIWarningMessageHook_t(SteamAPIDebugTextHook);  
  128.             SteamClient.SetWarningMessageHook(m_SteamAPIWarningMessageHook);  
  129.         }  
  130.     }  
  131.   
  132.   
  133.     // OnApplicationQuit gets called too early to shutdown the SteamAPI.  
  134.     // Because the SteamManager should be persistent and never disabled or destroyed we can shutdown the SteamAPI here.  
  135.     // Thus it is not recommended to perform any Steamworks work in other OnDestroy functions as the order of execution can not be garenteed upon Shutdown. Prefer OnDisable().  
  136.     private void OnDestroy() {  
  137.         if (s_instance != this) {  
  138.             return;  
  139.         }  
  140.   
  141.         s_instance = null;  
  142.   
  143.         if (!m_bInitialized) {  
  144.             return;  
  145.         }  
  146.   
  147.         SteamAPI.Shutdown();  
  148.     }  
  149.   
  150.     private void Update() {  
  151.         if (!m_bInitialized) {  
  152.             return;  
  153.         }  
  154.   
  155.         // Run Steam client callbacks  
  156.         SteamAPI.RunCallbacks();  
  157.     }  
  158. }  


-----------------------------------------------------------------------------------------------------
 
 

第二步:

如何提交游戏版本

在提交游戏之前先对内容上传软件进行配置:

1、找到sdk oolsContentBuilderscripts目录,该目录下有两个配置文件名需要更改

   app_build_自己的APPID.vdf,  depot_build_自己的APPID.vdf

2、假如我的APP ID 为 "55220"  ,修改app_build_55220,"appid","depots"内容如下:

  1. "appbuild"  
  2. {  
  3.     "appid" "<span style="color:#ff0000;background-color: rgb(255, 204, 153);">55220</span>"  
  4.     "desc" "Your build description here" // description for this build  
  5.     "buildoutput" "..output" // build output folder for .log, .csm & .csd files, relative to location of this file  
  6.     "contentroot" "..content" // root content folder, relative to location of this file  
  7.     "setlive"   "" // branch to set live after successful build, non if empty  
  8.     "preview" "0" // to enable preview builds  
  9.     "local" ""  // set to flie path of local content server   
  10.       
  11.     "depots"  
  12.     {  
  13.         "<span style="color:#ff0000;background-color: rgb(255, 204, 153);">55221</span>" "depot_build_<span style="color:#ff0000;background-color: rgb(255, 204, 153);">55221</span>.vdf"  
  14.     }  
  15. }  

修改depot_build_55221,修改 "DepotID" ,"ContentRoot","LocalPath" 内容如下:

  1. "DepotBuildConfig"  
  2. {  
  3.     // Set your assigned depot ID here  
  4.     "DepotID" "<span style="font-size: 14.4px; font-family: Lato, proxima-nova, "Helvetica Neue", Arial, sans-serif; background-color: rgb(255, 204, 153);"><span style="color:#ff0000;">55221</span></span>"  
  5.   
  6.     // Set a root for all content.  
  7.     // All relative paths specified below (LocalPath in FileMapping entries, and FileExclusion paths)  
  8.     // will be resolved relative to this root.  
  9.     // If you don‘t define ContentRoot, then it will be assumed to be  
  10.     // the location of this script file, which probably isn‘t what you want  
  11.     "ContentRoot"   "<span style="color:#ff0000;background-color: rgb(255, 204, 153);">D:SDK硬盘位置steamworks_sdk_138asdk oolsContentBuildercontent</span>"   
  12.   
  13.     // include all files recursivley  
  14.   "FileMapping"  
  15.   {  
  16.     // This can be a full path, or a path relative to ContentRoot     
  17.     "LocalPath" "<span style="color:#ff0000;background-color: rgb(255, 204, 153);">.windows_content*</span>"  
  18.       
  19.     // This is a path relative to the install folder of your game  
  20.     "DepotPath" "."  
  21.       
  22.     // If LocalPath contains wildcards, setting this means that all  
  23.     // matching files within subdirectories of LocalPath will also  
  24.     // be included.  
  25.     "recursive" "1"  
  26.   }  
  27.   
  28.     // but exclude all symbol files    
  29.     // This can be a full path, or a path relative to ContentRoot  
  30.   "FileExclusion" "*.pdb"  
  31. }  

3、找到sdk oolsContentBuildercontent目录在目录下新增文件夹 windows_content

4、复制需要提交的游戏文件至 windows_content 目录下

5、找到sdk oolsContentBuilder目录下的runbuild.bat右击编辑 更改内容如下:

 
  1. buildersteamcmd.exe +loginsteam用户名 密码 +run_app_build_http ..scriptsapp_build_自己的APPID.vdf   
 
游戏测试无误的时候就双击runbuild.bat 等待上传成功了 
 
暂时先写这么多,后面还会更新 steamwork商店的一些配置 
 
 
注:博文转自http://blog.csdn.net/tonye129/article/details/54311481

三人团队如何斩获最佳独立游戏大奖|googleplay开发者中文播客节目

提示:如图文未加载,请刷新重试提示:如图文未加载,请刷新重试本期简介心动网络作为一家主要布局商业游戏全球化研运的企业,在游戏出海方面的成绩单一向亮眼,不论是2020年获得了BestIndie的《恶... 查看详情

如何在 Unity 编辑器中运行两个游戏窗口

...是什么意思?如果一个人基本上可以在编辑器中拥有两个独立的窗口,而不是仅限于一个:为什么会有用?它主要用于网络。在测试网络多人游戏时,通常需要等待很长时间才能创建独立版本来测试和调试事件,而且在单机上调... 查看详情

游戏循环帧独立

】游戏循环帧独立【英文标题】:GameLoopframeindependent【发布时间】:2012-05-2415:06:25【问题描述】:是否可以让游戏循环尽可能快地运行?目前我可以设置我想要的fps,因此在我的游戏将发送到的所有设备上都有一个恒定的fps。然... 查看详情

支付宝微信网银第三方支付靠谱稳定对接开发

...搭建,支付通道申请,支付接口对接,原生支付宝网关支付!独立后台,D0实时结算,API批量代付接口JR/BC/QP菠菜奔驰游戏等稳定安全通道! 查看详情

luckclub-sdt去中心化的游戏

...。SDT沿用以太坊智能合约账本,与币圈无缝对接,不仅是独立的数字货币。同时,它也是全球知名游戏开发公司LUCKCLUB(幸运俱乐部)旗下首款区块链去中心化游戏SuperSingleDOG(超级单身狗)的游戏代币。不管是虚拟货币,还是... 查看详情

张书乐:把独立游戏纳入“计划”,市场何在?

...了吸金大户《王者荣耀》外,或许第二热门话题,就属于独立游戏这个备受巨头瞩目的东东了。就在7月末结束的Chinajoy时,一个在一线游戏公司打拼了多年的程序员,很兴奋的在微信上给我留了个言:我决定不再依附任何游戏公... 查看详情

这是 FPS 独立游戏循环的良好实现吗?

】这是FPS独立游戏循环的良好实现吗?【英文标题】:IsthisagoodimplementationofaFPSindependantgameloop?【发布时间】:2010-10-1816:05:21【问题描述】:我目前有一些接近于以下实现的FPS独立游戏循环,用于基于物理的游戏。它在我测试过的... 查看详情

如果 CALayer 边界如何独立地 CALayer 图像缩放

】如果CALayer边界如何独立地CALayer图像缩放【英文标题】:HowtoCALayer\'simagescaleindependentlyofCALayer\'sbounds【发布时间】:2012-02-1122:18:34【问题描述】:我找不到这个问题的答案。我想知道如何使calayer中的图像大小小于calayer的边界大... 查看详情

支付宝接口对接开发过程

...软件开发的公司,可以称之为ISV(IndependentSoftwareVendors,独立软件开发商)。本文定位的角色即是ISV。  那么我们ISV开发的系统,可能是传统电商网站、可能是微商城、可能是APP等等,无论是哪种方式,在目前的中国,都不应... 查看详情

Unity:本地(LAN)对接会错误

...4-2114:52:33【问题描述】:我正在尝试创建一个简单的多人游戏。我已经设置了一个配对系统,当设备连接到互联网时它工作正常,即成功创建了一个在线大厅。但是当我尝试在无法访问互联网的本地网络上创建一个大厅时,什么... 查看详情

独立游戏sunset——二次元横版动作游戏

SUNSET是一个动漫风横版动作同人游戏,讲述了在虚拟现实发达的未来,白帽黑客们与骇客的斗争游戏中你不仅可以获得传统动作游戏的爽快打击感,还能运用各种科技道具体验到不一样的快感游戏由南昌大学游戏部的sols&茶炉... 查看详情

用于独立游戏后端的 Aurora、Redshift 和 DynamoDB?

】用于独立游戏后端的Aurora、Redshift和DynamoDB?【英文标题】:AuroravsRedshiftvsDynamoDBforIndieGameBackend?【发布时间】:2017-12-2105:21:25【问题描述】:我已经阅读了大量关于这些数据库的内容,但仍然不确定该使用什么。我需要一个我... 查看详情

如何在独立模式或编辑器模式下退出

】如何在独立模式或编辑器模式下退出【英文标题】:HowdoIquitinstandaloneorineditormode【发布时间】:2017-02-0120:07:28【问题描述】:我在windows1064bit上使用unity5.4.1f1Personal我将解释到目前为止我所做的所有步骤以及我尝试过的所有事... 查看详情

设计模式之一

...,使他们能互相替换且算法的变换与使用算法的对象相互独立。简单来说是将变化的和不变得分离,对接口编程,不对实现编程(少用继承)。 下面举个例子:Joe上班的公司做了一套相当成功的模拟鸭子游戏:SirmDuck。游戏中... 查看详情

如何验证手机是不是已对接?

】如何验证手机是不是已对接?【英文标题】:Howtoverifyifthephoneisdocked?如何验证手机是否已对接?【发布时间】:2011-02-0809:26:16【问题描述】:我正在寻找一种方法来验证手机是否在Android1.6(API4)上对接(车载底座、桌面底座)... 查看详情

在安全且独立于平台的 Unity 中保存游戏数据的最佳方式

】在安全且独立于平台的Unity中保存游戏数据的最佳方式【英文标题】:ThebestwaytosavegamedatainUnitythat\'ssecure&platfromindependent【发布时间】:2019-01-2602:00:12【问题描述】:我正在寻找一种方法来为我的游戏保存用户进度,我正在... 查看详情

一个人独立开发3d游戏引擎可能吗?

作者:孙志超链接:https://www.zhihu.com/question/24733255/answer/42000966来源:知乎著作权归作者所有,转载请联系作者获得授权。当然可以,但难道有个引擎,就可以做出真正商业化的游戏么?而且国产游戏大部分是网游啊。几年前的... 查看详情

国际快递查询轨迹api接口如何对接?

像UPS,联邦快递这些API接口怎么对接参考技术A需要用一个系统对接另一个系统,需要技术人员对接接口,看是否需要改变字段或者开发语言等等,同时对接完成后需要两边的系统测试数据传输的稳定性,这边建议使用快递鸟这... 查看详情