Getting achievement groups
Get the achievement groups in the game.
Since there can be many achievement groups in your game, it is not feasible to retrieve all achievement groups at the same time because of processing and network constraints. Therefore, is used so that achievement groups are retrieved in parts.
Getting achievement groups
To get achievement groups, use the GetAchievementGroups method in CoreServices.
There are a few key parameters to take note of:
string? query: A full-text search query.int pageSize: The number of achievement groups to retrieve at a time. Defaults to 30, maximum 30.AchievementGroupsSortField sortBy: The field to sort the achievement groups by.SortDirection sortDirection: The direction to sort the achievement groups by.
A cursor (instance of AchievementGroupsCursor) is returned, and you can use the HasNext attribute of the cursor to determine if the pagination has reached the last page, and use the Next() method to retrieve the next page. Each page is a list of AchievementGroup instances, containing information such as the achievement group ID, display name and short description.
Example - Get achievement groups with pagination
var cursor = CoreServices.GetAchievementGroups(
"Gold",
sortBy: AchievementGroupsSortField.DisplayName,
sortDirection: SortDirection.Descending
);
while (cursor.HasNext)
{
var achievementGroups = await cursor.Next();
foreach (var achievementGroup in achievementGroups)
{
Debug.Log($"Achievement group {achievementGroup.DisplayName} retrieved.");
/* ... */
}
}However, if you would like to retrieve every achievement group with one method call, you can list the brief information of all achievement groups instead, using the ListAllAchievementGroups method in CoreServices. The parameters are the same as GetAchievementGroups; however, querying achievement groups is unavailable.
This will return a list of ListedAchievementGroup instances, containing only the achievement group ID and display name.
Example - List all core achievement group information
var achievementGroups = await CoreServices.ListAllAchievementGroups(
AchievementGroupsSortField.DisplayName,
SortDirection.Ascending
);
foreach (var achievementGroup in achievementGroups)
{
Debug.Log($"Achievement Group {achievementGroup.DisplayName} retrieved.");
}Getting detailed information about an achievement
You can call the GetDetailedAchievementGroup method in any achievement group class, including AchievementGroup and ListedAchievementGroup, to get the detailed information, such as the detailed description.
var detailedSampleAchievementGroup = await sampleAchievementGroup.GetDetailedAchievementGroup();
Debug.Log($"Achievement Group: {detailedSampleAchievementGroup.DisplayName}, Detailed Description: {detailedSampleAchievementGroup.DetailedDescription}");Last updated