Class Leaderboard
Represents an Instant Game leaderboard.
Inherited Members
Namespace: Meta.InstantGames
Assembly: Unity.Meta.InstantGames.Sdk.dll
Syntax
public class Leaderboard : JsObject
Constructors
Leaderboard()
Construct an instance of Leaderboard
Declaration
public Leaderboard()
Methods
GetConnectedPlayerEntriesAsync(double?, double?)
Retrieves the leaderboard score entries of the current player's connected players, including the current player, ordered by local rank within the set of connected players. Exceptions: NETWORK_FAILURE, RATE_LIMITED.
Declaration
public WebTask<LeaderboardEntry[]> GetConnectedPlayerEntriesAsync(double? count = null, double? offset = null)
Parameters
| Type | Name | Description |
|---|---|---|
| double? | count | The number of entries the system attempts to fetch from the leaderboard. Defaults to 10 if not specified. Currently, up to a maximum of 100 entries may be fetched per query. |
| double? | offset | The offset from the set of ordered connected player score entries to fetch from. Defaults to 0 if not specified. |
Returns
| Type | Description |
|---|---|
| WebTask<LeaderboardEntry[]> | A WebTask that resolves with anyLeaderboardEntry that matches the query. |
GetContextID()
Returns the ID of the context that the leaderboard is associated with.
Declaration
public string GetContextID()
Returns
| Type | Description |
|---|---|
| string | The ID of the context that the leaderboard is associated with, or |
GetEntriesAsync(double?, double?)
Retrieves a set of leaderboard entries, ordered by score ranking in the leaderboard. Exceptions: NETWORK_FAILURE, RATE_LIMITED.
Declaration
public WebTask<LeaderboardEntry[]> GetEntriesAsync(double? count = null, double? offset = null)
Parameters
| Type | Name | Description |
|---|---|---|
| double? | count | The number of entries the system attempts to fetch from the leaderboard. Defaults to 10 if not specified. Currently, up to a maximum of 100 entries may be fetched per query. |
| double? | offset | The offset from the top of the leaderboard that entries are fetched from. Defaults to 0 if not specified. |
Returns
| Type | Description |
|---|---|
| WebTask<LeaderboardEntry[]> | A WebTask that resolves with anyLeaderboardEntry that matches the query. |
GetEntryCountAsync()
Fetches the total number of player entries in the leaderboard. Exceptions: NETWORK_FAILURE, RATE_LIMITED.
Declaration
public WebTask<double> GetEntryCountAsync()
Returns
| Type | Description |
|---|---|
| WebTask<double> | A WebTask<T> that resolves with the total number of player entries in the leaderboard. |
GetName()
Returns the name of the leaderboard.
Declaration
public string GetName()
Returns
| Type | Description |
|---|---|
| string | The name of the leaderboard. |
GetPlayerEntryAsync()
Retrieves the leaderboard's entry for the current player. Exceptions: NETWORK_FAILURE, INVALID_OPERATION, RATE_LIMITED.
Declaration
public WebTask<LeaderboardEntry> GetPlayerEntryAsync()
Returns
| Type | Description |
|---|---|
| WebTask<LeaderboardEntry> | A WebTask that resolves with the current LeaderboardEntry for the player, or |
SetScoreAsync(double, string)
Updates the player's score. If the player has an existing score, the old score is replaced only if the new score is higher. If the leaderboard is associated with a specific context, the game must be in that context to set a score for the player. Exceptions: LEADERBOARD_WRONG_CONTEXT, NETWORK_FAILURE, INVALID_PARAM, INVALID_OPERATION, RATE_LIMITED.
Declaration
public WebTask<LeaderboardEntry> SetScoreAsync(double score, string extraData = null)
Parameters
| Type | Name | Description |
|---|---|---|
| double | score | The new score for the player. Must be a whole number. |
| string | extraData | Optional metadata to associate with the stored score. Must be less than 2 KB in size. |
Returns
| Type | Description |
|---|---|
| WebTask<LeaderboardEntry> | A WebTask that resolves with the currentLeaderboardEntrys for the player after the update. |