PICO Unity Platform SDK
LeaderboardService Class Reference

Static Public Member Functions

static Task< LeaderboardListGet (string leaderboardName)
 Gets the information for a specified leaderboard. More...
 
static Task< LeaderboardEntryListGetEntries (string leaderboardName, int pageSize, int pageIdx, LeaderboardFilterType filter, LeaderboardStartAt startAt)
 Gets a list of entries. More...
 
static Task< LeaderboardEntryListGetEntriesAfterRank (string leaderboardName, int pageSize, int pageIdx, ulong afterRank)
 Gets a list of entries after a specified rank. More...
 
static Task< LeaderboardEntryListGetEntriesByIds (string leaderboardName, int pageSize, int pageIdx, LeaderboardStartAt startAt, string[] userIDs)
 Gets a list of entries for specified users. More...
 
static Task< bool > WriteEntry (string leaderboardName, long score, byte[] extraData=null, bool forceUpdate=false)
 Writes an entry to a leaderboard. More...
 
static Task< bool > WriteEntryWithSupplementaryMetric (string leaderboardName, long score, long supplementaryMetric, byte[] extraData=null, bool forceUpdate=false)
 Writes an entry to a leaderboard. The entry can include the supplementary metric for tiebreakers. More...
 

Member Function Documentation

◆ Get()

static Task< LeaderboardList > Get ( string  leaderboardName)
static

Gets the information for a specified leaderboard.

Parameters
leaderboardNameThe name of the leaderboard to get information for.
Returns

Request information of type Task, including the request ID, and its response message will contain data of type LeaderboardList.

Error Code Error Message
10701 request server failed
10703 checking parameter failed
10704 leaderboard is not exist

A message of type MessageType.Leaderboard_Get will be generated in response. First call message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type LeaderboardList. Extract the payload from the message handle with message.Data.

◆ GetEntries()

static Task< LeaderboardEntryList > GetEntries ( string  leaderboardName,
int  pageSize,
int  pageIdx,
LeaderboardFilterType  filter,
LeaderboardStartAt  startAt 
)
static

Gets a list of entries.

Parameters
leaderboardNameThe name of the leaderboard whose entries are to be returned.
pageSizeThe number of entries to return on each page.
pageIdxDefines which page of entries to return. The first page index is 0. For example, if you want to get the first page of entries, pass 0; if you want to get the second page of entries, pass 1.
filterRestricts the scope of entries to return:
  • 0: None (returns all entries of the specified leaderboard)
  • 1: Friends (returns the entries of the friends of the current logged-in user)
  • 2: Unknown (returns no entry)
  • 3: UserIds (returns the entries of specified users)
startAtDefines where to start returning leaderboard entries, the enumerations are:
  • 0: Top (return entries from top 1)
  • 1: CenteredOnViewer (place the current logged-in user's entry in the middle of the list on the first page. For example, if the total number of entries is 10, pageSize is set to 5, and the user's rank is top 5, the ranks displayed on the first page will be top 3, 4, 5, 6, and 7. Top 1 and 2 will not be displayed, and top 8, 9, and 10 will be displayed on the second page)
  • 2: CenteredOnViewerOrTop (place the current logged-in user's entry on the top of the list on the first page. For example, if the total number of entries is 10, pageSize is set to 5, and the user's rank is top 5, the ranks displayed on the first page will be top 5, 6, 7, 8, and 9. Top 1, 2, 3, and 4 will not be displayed, and top 10 will be displayed on the second page)
  • 3: Unknown (returns an empty list)
Returns

Request information of type Task, including the request ID, and its response message will contain data of type LeaderboardEntryList.

Error Code Error Message
3006501 request server failed
3006503 checking parameter failed
3006504 leaderboard is not exist
3006506 load leaderboard data failed
3006509 get friend failed
3006510 get user account failed

A message of type MessageType.Leaderboard_GetEntries will be generated in response. First call message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type LeaderboardEntryList. Extract the payload from the message handle with message.Data.

◆ GetEntriesAfterRank()

static Task< LeaderboardEntryList > GetEntriesAfterRank ( string  leaderboardName,
int  pageSize,
int  pageIdx,
ulong  afterRank 
)
static

Gets a list of entries after a specified rank.

Parameters
leaderboardNameThe name of the leaderboard whose entries are to be returned.
pageSizeThe number of entries to return on each page.
pageIdxDefines which page of entries to return. The first page index is 0. For example, if you want to get the first page of entries, pass 0; if you want to get the second page of entries, pass 1.
afterRankDefines after which rank to return entries.
Returns

Request information of type Task, including the request ID, and its response message will contain data of type LeaderboardEntryList.

Error Code Error Message
10701 request server failed
10703 checking parameter failed
10704 leaderboard is not exist
10706 load leaderboard data failed
10709 get friend failed
10710 get user account failed

A message of type MessageType.Leaderboard_GetEntriesAfterRank will be generated in response. First call message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type LeaderboardEntryList. Extract the payload from the message handle with message.Data.

◆ GetEntriesByIds()

static Task< LeaderboardEntryList > GetEntriesByIds ( string  leaderboardName,
int  pageSize,
int  pageIdx,
LeaderboardStartAt  startAt,
string[]  userIDs 
)
static

Gets a list of entries for specified users.

Parameters
leaderboardNameThe name of the leaderboard whose entries are to be returned.
pageSizeThe number of entries to return on each page.
pageIdxDefines which page of entries to return. The first page index is 0. For example, if you want to get the first page of entries, pass 0; if you want to get the second page of entries, pass 1.
startAtDefines where to start returning leaderboard entries, the enumerations are:
  • 0: Top (return entries from top 1)
  • 1: CenteredOnViewer (place the current logged-in user's entry in the middle of the list on the first page. For example, if the total number of entries is 10, pageSize is set to 5, and the user's rank is top 5, the ranks displayed on the first page will be top 3, 4, 5, 6, and 7. Top 1 and 2 will not be displayed, and top 8, 9, and 10 will be displayed on the second page)
  • 2: CenteredOnViewerOrTop (place the current logged-in user's entry on the top of the list on the first page. For example, if the total number of entries is 10, pageSize is set to 5, and the user's rank is top 5, the ranks displayed on the first page will be top 5, 6, 7, 8, and 9. Top 1, 2, 3, and 4 will not be displayed, and top 10 will be displayed on the second page)
  • 3: Unknown (returns an empty list)
userIDsThe ID list of the users to get entries for.
Returns

Request information of type Task, including the request ID, and its response message will contain data of type LeaderboardEntryList.

Error Code Error Message
10701 request server failed
10703 checking parameter failed
10704 leaderboard is not exist
10706 load leaderboard data failed
10709 get friend failed
10710 get user account failed

A message of type MessageType.Leaderboard_GetEntriesByIds will be generated in response. First call message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type LeaderboardEntryList. Extract the payload from the message handle with message.Data.

◆ WriteEntry()

static Task< bool > WriteEntry ( string  leaderboardName,
long  score,
byte[]  extraData = null,
bool  forceUpdate = false 
)
static

Writes an entry to a leaderboard.

Parameters
leaderboardNameThe name of the leaderboard to write an entry to.
scoreThe score to write.
extraDataA 2KB custom data field that is associated with the leaderboard entry. This can be a game replay or anything that provides more details about the entry to the viewer.
forceUpdateDefines whether to force update the score. If set to true, the score always updates even if it is not the user's best score.
Returns

Request information of type Task, including the request ID, and its response message will contain data of type bool.

Error Code Error Message
10701 request server failed
10703 checking parameter failed
10704 leaderboard is not exist
10705 no write permission
10706 load leaderboard data failed
10707 save leaderboard data failed
10708 extra data too long
10714 out of write time limit

A message of type MessageType.Leaderboard_WriteEntry will be generated in response. First call message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type bool. Extract the payload from the message handle with message.Data.

◆ WriteEntryWithSupplementaryMetric()

static Task< bool > WriteEntryWithSupplementaryMetric ( string  leaderboardName,
long  score,
long  supplementaryMetric,
byte[]  extraData = null,
bool  forceUpdate = false 
)
static

Writes an entry to a leaderboard. The entry can include the supplementary metric for tiebreakers.

Parameters
leaderboardNameThe name of the leaderboard to write an entry to.
scoreThe score to write.
supplementaryMetricThe metric that can be used for tiebreakers.
extraDataA 2KB custom data field that is associated with the leaderboard entry. This can be a game replay or anything that provides more details about the entry to the viewer.
forceUpdateDefines whether to force update the score. If set to true, the score always updates even if it is not the user's best score.
Returns

Request information of type Task, including the request ID, and its response message will contain data of type bool.

Error Code Error Message
10701 request server failed
10703 checking parameter failed
10704 leaderboard is not exist
10705 no write permission
10706 load leaderboard data failed
10707 save leaderboard data failed
10708 extra data too long
10714 out of write time limit

A message of type MessageType.Leaderboard_WriteEntryWithSupplementaryMetric will be generated in response. First call message.IsError() to check if any error has occurred. If no error has occurred, the message will contain a payload of type bool. Extract the payload from the message handle with message.Data.