Achievement Object

Definition

1
public class AchievementObject : ScriptableObject
Copied!
The AchievementObject is generated by importing achievements from the Steam Developer Portal. You do this by selecting your Steam Settings object and expanding the Achievements section and clicking the Import button.
The simulation must be running (click Play in Unity) in order for this to work
This is becuase the Steam API must be initalized and updating to return results

Fields and Attributes

Id

1
public string Id => get;
Copied!
Returns the ID of the achievement, note in the editor you can both read and write this value however in a build you can only read this value. The write operation is only used when importing achievments from Steam whcih can only happen at development time in the editor.

Name

1
public string Name => get;
Copied!
Returns the display name of the achievement, as with ID, in builds this can only be read, in the editor however it can be read and writen to in order to support the import of achievements at development time.

Description

1
public string Description => get;
Copied!
Returns the description of the achievement, as with ID, in builds this can only be read, in the editor however it can be read and written to in order to support the import of achievmeents at development time.

Hidden

1
public bool Hidden => get;
Copied!
Returns the hidden flag for this achievment, as with ID, in builds this can only be read, in the editor however it can be read and written to in order to support the import of achievements at development time.

IsAchieved

1
public bool IsAchieved { get; set; }
Copied!
This can be read to determin if the user has unlocked this achievement, this can be writen to in order to unlock this achievement.
Note that if the achievement is set to write trusted only then the attempt to write to this achievement will simply do nothing.

Methods

Unlock

1
public void Unlock();
Copied!
1
public void Unlock(CSteamID user);
Copied!
Unlocks the achievement for the local user or if on a game server pass in the user ID to unlock the achievement for a specific user.
The server version (takes the user paramiter) will only work from Steam Game Servers and only when the indicated user has been authenticated.
When in a client build this is the same as
1
achievement.IsAchieved = true;
Copied!

ClearAchievement

1
public void CLearAchievement();
Copied!
1
public void ClearAchievement(CSteamID user);
Copied!
Clears the achievement state for the local user in client builds (do not pass the user paramiter). For server builds you would pass in the user paramiter to clear the achievement for the indicated user. The server version (takes the user paramiter) will only work from Steam Game Servers and only when the indicated user has been authenticated.

GetAchievementStatus

1
public bool GetAchievementStatus(CSteamID user);
Copied!
Gets the achievement state for this achievement for the indicated user. This is only available from Steam Game Servers and only when the indicated user has been authhenticated and its states requested. See the API.StatsAndAchievements interface for details

Store

1
public void Store()
Copied!
This simply calls StatsAndAchievements.Client.StoreStats() and is only used on client builds to store any updated stats and achievements to the backend.
You should not call this every time you update the value of a stat or achievement. The inteded purpose from Valve is that you can update your stats and acheivements in real time during gameplay and then at key points such as at the end of a mission or similar store those stats to the backend.
The notification of a stat or achievemnt being updated only happens when you call store stats or when the game closes.
The Store Stats funciton is rate limited so if you call it to frequiently the Steam API will ignore you.