无法将类型“Steamworks.CSteamID”隐式转换为“float”

Cannot implicitly convert type `Steamworks.CSteamID' to `float'

我目前正在使用 Steamworks.net Unity3d 和 C#。我想做的是获取 Steam 用户 ID,在本例中是我自己的 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'。存在显式转换(是否缺少转换?)

这让我很困惑。我尝试对 google 进行研究以找到可能的修复方法,但找不到任何东西。有人可以帮忙吗?

编辑:

我试过了,但没用:

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");
        }
    }
}

您的 GetSteamID() return 类型 Steamworks.CSteamID 的对象不能分配给类型 float.

的变量 steamID

CSteamID 结构中有一个名为 m_SteamIDulong 变量。这就是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");
        }
    }
}