Links

Achievement Object

Like what your seeing?

Consider supporting us as a GitHub Sponsor and get instant access to all our Unity assets, exclusive tools and assets, escalated support and issue tracking and our gratitude. These articles are made possible by our GitHub Sponsors ... become a sponsor today!

Introduction

public class AchievementObject : ScriptableObject
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

public string Id => get;
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

public string Name => get;
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

public string Description => get;
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

public bool Hidden => get;
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

public bool IsAchieved { get; set; }
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

public void Unlock();
public void Unlock(CSteamID user);
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
achievement.IsAchieved = true;

ClearAchievement

public void CLearAchievement();
public void ClearAchievement(CSteamID user);
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

public bool GetAchievementStatus(CSteamID user);
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

public void Store()
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.