C # steamworks SDK API package of abutting unity steamworks.net

The unity steam line project platform, if access steamworks SDK can provide a better experience. Find someone with C # package when steam is provided by the official SDK C ++ code, you can also choose to access sdk native steamworks SDK, the official link: https: //steamworks.github.io/. The above link contains documentation and sdk Download. 

This SDK covers most of the functionality provided by the native steamworks, such as: state of the memory and achievements, leaderboards, user authorization, matchmaking, steam clouds, etc. functions, the document has a detailed overview. They also found the course very careful use and C ++ the same method name to encapsulate the C # methods , such control in the course of these official documents can easily be found in the api sdk need to call their own. Because of my needs are currently limited achievements, leaderboards and user state storage volume, the following will unfold around three modules.

First, install the SDK

1. Download the Steamworks.NET .unitypackage  https://github.com/rlabrecque/Steamworks.NET/releases , the windows can directly download the zip  https://github.com/rlabrecque/Steamworks.NET/archive/master. zip

2. The package of unity introduced Assets / directory.

Here Insert Picture Description

Once imported, you can see added a new three folders: Editer; Plugins; Scripts;

Here Insert Picture Description

3. Open the unity project, will automatically generate steam_appid.txt to the home directory of the project. Open  steam_appid.txt and  480 modify for your own AppId.

4. Add scrpts / Steamworks.net / SteamManager assembly to the game object,

打开Scripts文件夹下的 Steamworks. NET 文件夹,打开SteamManager脚本,
将 if 条件中的 AppId_t.Invalid 改为 (AppId_t)480 或者 new AppId_t(480) ,
把 480 改成自己在 steamworks 上花100刀买的那个游戏编号。 

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

5. 测试Steam API 调用

后主要脚本SteamManager,提供了Steamworks.NET的一些基础API供大家使用。

首先第一步,作为测试,可以新脚本SteamScript.cs并加入如下代码:
 

public class SteamScript : MonoBehaviour {
    void Start() {
        if(SteamManager.Initialized) {
            string name = SteamFriends.GetPersonaName();
            Debug.LogError(name);
        }
    }
}

注意我们在调用任何Steamworks方法前需要先确认steam是否初始化完成,即SteamManager.Initialized

发布了85 篇原创文章 · 获赞 30 · 访问量 27万+

Guess you like

Origin blog.csdn.net/qq_42672770/article/details/104444771