gpt4 book ai didi

c# - 无法将类型 `Steamworks.CSteamID' 隐式转换为 `float'

转载 作者:太空宇宙 更新时间:2023-11-03 19:45:10 25 4
gpt4 key购买 nike

我目前正在将 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' 隐式转换为 float'。存在显式转换(是否缺少强制转换?)

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

编辑:

我试过了,但没用:

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() 返回类型为 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");
}
}
}

关于c# - 无法将类型 `Steamworks.CSteamID' 隐式转换为 `float',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46461760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com