unity-game-enginesteamachievementssteamworks-api

Can't get the number of achievements from Unity game using Steamworks.NET


I was about to release a new game on Steam. It is a Unity game in which I use Steamworks.NET to get achievements from Steam.

I use the following code:

if (SteamManager.Initialized) {
    string name = SteamFriends.GetPersonaName ();
    Debug.Log (name+" - "+SteamUser.GetSteamID() );

    m_GameID = new CGameID (SteamUtils.GetAppID ());
    Debug.Log ("number of achievements: " + SteamUserStats.GetNumAchievements ());
    Debug.Log ("gameID: " + m_GameID);

} else {
    Debug.Log ("Steam not initialized");
}

m_GameID is set correctly (I use a steam_appid.txt file).

I use it for all my steam games, but for some reason SteamUserStats.GetNumAchievements () always returns 0.

I published the achievements on Steam, but still don't know why this is happening.

How I can correct that?


Solution

  • I discover the problem.

    I just need to call SteamUserStats.RequestCurrentStats() in the update method. It's working now.