1

我目前正在使用带有 Unity3d 和 C# 的 Steamworks.net。我想要做的是获取 Steam 用户 ID,在这种情况下是我自己的,然后执行一个函数。

这是我到目前为止所拥有的:

private static float berdyevID = 76561198040013516;
private static float steamID;


void Start() {

    if(SteamManager.Initialized) {

        string name = SteamFriends.GetPersonaName();

        // get steam user id
        steamID = Steamworks.SteamUser.GetSteamID();

        // see if it matches
        if (berdyevID == steamID) {

            Debug.Log ("Steam ID did match");
        } else {

            Debug.Log ("Steam ID did not match");
        }


    }

}

我从 Unity 收到一个错误,其中指出:

无法隐式转换类型Steamworks.CSteamID' tofloat'。存在显式转换(您是否缺少演员表?)

这让我很困惑。我尝试在谷歌上进行研究以找到可能的解决方法,但找不到任何东西。任何人都可以帮忙吗?

编辑

我试过了,但没有用:

private static ulong berdyevID = 76561198040013516;
private static ulong steamID;

void Start() {

    if(SteamManager.Initialized) {

        string name = SteamFriends.GetPersonaName();

        // get steam user id
        steamID = Steamworks.SteamUser.GetSteamID();

        // see if it matches
        if (berdyevID == steamID) {

            Debug.Log ("Steam ID did match");
        } else {

            Debug.Log ("Steam ID did not match");
        }
    }
}
4

1 回答 1

5

GetSteamID()返回一个类型的对象,该对象不能分配给typeSteamworks.CSteamID的变量。steamIDfloat

结构中有一个ulong名为m_SteamIDvariable 的变量CSteamID。这就是id所在的位置。

private static ulong berdyevID = 76561198040013516;
private static ulong steamID;


void Start() {

    if(SteamManager.Initialized) {

        string name = SteamFriends.GetPersonaName();

        // get steam user id
        steamID = Steamworks.SteamUser.GetSteamID().m_SteamID;

        // see if it matches
        if (berdyevID == steamID) {

            Debug.Log ("Steam ID did match");
        } else {

            Debug.Log ("Steam ID did not match");
        }
    }
}
于 2017-09-28T05:45:34.670 回答