I'm currently using Steamworks.net with Unity3d and C#. What I want to do is to get Steam users ID, in this case my own and then execute a function.
This is what I have so far:
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");
}
}
}
I am getting an error from Unity which states:
Cannot implicitly convert type Steamworks.CSteamID' to
float'. An explicit conversion exists (are you missing a cast?)
Which confuses me. I tried doing my research on google to find a possible fix, but couldn't find anything. Can anyone help?
EDIT:
I tried this but it didn't work:
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");
}
}
}
Your GetSteamID()
return an object of type Steamworks.CSteamID
which is not assignable to the variable steamID
of type float
.
There is a ulong
variable named m_SteamID
variable in the CSteamID
struct. That's where the id is located.
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");
}
}
}