Skip to main content
AR论坛
 首页 » 资源教程

如何将unity游戏接入steam(steamworks)

2016年10月26日 12:12:274540CSDN

今天我们来谈谈怎么把Unity游戏接入Steam

如何将unity游戏接入steam(steamworks) 资源教程

要想使用Steamworks.NET,请先确保成为steam的开发者(要在steam提交游戏,需要一次性缴纳100美元费用)

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

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

Steamwork安装步骤

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

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

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

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

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

安装sdk完成.

如何使用

下载SteamManagers.cs

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

完整C#接口请点击查看

注:需要在https://partner.steamgames.com/home下载sdk,里面有提交游戏的工具,在\sdk\tools\ContentBuilder\builder

        在https://partner.steamgames.com/home/steamworks可以查看文档

        在http://steamworks.github.io/gettingstarted/可以查看C#接口的使用方式 

       // Ensure that you own a license for the AppId on your active Steam account  

        // If your AppId is not completely set up. Either in Release State: Unavailable, or if it's missing default packages.  

        // Valve's documentation for this is located here:  

        // https://partner.steamgames.com/documentation/getting_started  

        // https://partner.steamgames.com/documentation/example // Under: Common Build Problems  

        // https://partner.steamgames.com/documentation/bootstrap_stats // At the very bottom  

        // If you're running into Init issues try running DbgView prior to launching to get the internal output from Steam.  

        // http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx  

        m_bInitialized = SteamAPI.Init();  

        if (!m_bInitialized) {  

            Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this);  

            return;  

        }  

        s_EverInialized = true;  

    }  

    // This should only ever get called on first load and after an Assembly reload, You should never Disable the Steamworks Manager yourself.  

    private void OnEnable() {  

        if (s_instance == null) {  

            s_instance = this;  

        }  

        if (!m_bInitialized) {  

            return;  

        }  

        if (m_SteamAPIWarningMessageHook == null) {  

            // Set up our callback to recieve warning messages from Steam.  

            // You must launch with "-debug_steamapi" in the launch args to recieve warnings.  

            m_SteamAPIWarningMessageHook = new SteamAPIWarningMessageHook_t(SteamAPIDebugTextHook);  

            SteamClient.SetWarningMessageHook(m_SteamAPIWarningMessageHook);  

        }  

    }  

    // OnApplicationQuit gets called too early to shutdown the SteamAPI.  

    // Because the SteamManager should be persistent and never disabled or destroyed we can shutdown the SteamAPI here.  

    // 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().  

    private void OnDestroy() {  

        if (s_instance != this) {  

            return;  

        }  

        s_instance = null;  

        if (!m_bInitialized) {  

            return;  

        }  

        SteamAPI.Shutdown();  

    }  

    private void Update() {  

        if (!m_bInitialized) {  

            return;  

        }  

        // Run Steam client callbacks  

        SteamAPI.RunCallbacks();  

    }  

}  

评论列表暂无评论
发表评论