Essential Kit
Loading...
Searching...
No Matches
GameServices

Provides cross-platform interface to easily integrate popular social gaming functionalities such as achievements, leaderboards on your mobile games. More...

Static Public Member Functions

static ILeaderboard CreateLeaderboard (string leaderboardId)
 Creates a new instance of leaderboard object.
 
static void LoadLeaderboards (EventCallback< GameServicesLoadLeaderboardsResult > callback)
 Loads the leaderboards.
 
static IAchievement CreateAchievement (string achievementId)
 Creates a new instance of achievement object.
 
static void LoadAchievementDescriptions (EventCallback< GameServicesLoadAchievementDescriptionsResult > callback)
 Loads the achievement descriptions from game server.
 
static void LoadAchievements (EventCallback< GameServicesLoadAchievementsResult > callback)
 Loads previously submitted achievement progress for the current local player.
 
static void ReportAchievementProgress (string achievementId, double percentageCompleted, CompletionCallback callback)
 Reports the local user's achievement progress to game server, using platform specific id.
 
static void ReportAchievementProgress (IAchievementDescription achievementDescription, double percentageCompleted, CompletionCallback callback)
 Reports the local user's achievement progress to game server.
 
static void ReportAchievementProgress (IAchievement achievement, double percentageCompleted, CompletionCallback callback)
 Reports the local user's achievement progress to game server.
 
static void LoadFriends (EventCallback< GameServicesLoadPlayerFriendsResult > callback)
 Loads the list of friends for the authenticated local player.
 
static void AddFriend (string playerId, EventCallback< bool > callback)
 Initiates a friend request to the specified player.
 
static void Authenticate ()
 Initiates authentication process for the local player on the device.
 
static void Signout ()
 Signout the local player on the device.
 
static void ReportScore (string leaderboardId, long value, CompletionCallback callback, string tag=null)
 Reports the score to game server.
 
static void ReportScore (ILeaderboard leaderboard, long value, CompletionCallback callback, string tag=null)
 Reports the score to game server.
 
static void ShowLeaderboards (LeaderboardTimeScope timescope=LeaderboardTimeScope.AllTime, EventCallback< GameServicesViewResult > callback=null)
 Opens the standard view to display all the leaderboards.
 
static void ShowLeaderboard (string leaderboardId, LeaderboardTimeScope timescope=LeaderboardTimeScope.AllTime, EventCallback< GameServicesViewResult > callback=null)
 Opens the standard view to display leaderboard scores corresponding to given id.
 
static void ShowLeaderboard (ILeaderboard leaderboard, LeaderboardTimeScope timescope=LeaderboardTimeScope.AllTime, EventCallback< GameServicesViewResult > callback=null)
 Opens the standard view to display leaderboard scores corresponding to given leaderboard.
 
static void ShowAchievements (EventCallback< GameServicesViewResult > callback=null)
 Opens the standard view to display achievement progress screen for the local player.
 
static void LoadServerCredentials (EventCallback< GameServicesLoadServerCredentialsResult > callback)
 Loads the server credentials.
 
Advanced Usage
static void Initialize (GameServicesUnitySettings settings)
 Initializes game services with custom settings created at runtime.
 
Obsolete methods
static void LoadPlayers (string[] playerIds, EventCallback< GameServicesLoadPlayersResult > callback)
 Loads the player details from game server.
 
static IScore CreateScore (string leaderboardId)
 Creates the score for specified leaderboard.
 
static IScore CreateScore (ILeaderboard leaderboard)
 Creates the score for specified leaderboard.
 

Properties

static ILocalPlayer LocalPlayer [get]
 Returns the local player.
 
static bool IsAuthenticated [get]
 A boolean value indicating whether this local player is authenticated.
 
static ILeaderboard[] Leaderboards [get]
 Returns the cached leaderboards array.
 
static IAchievementDescription[] AchievementDescriptions [get]
 Returns the cached achievement description array.
 
static IAchievement[] Achievements [get]
 Returns the cached achievements array.
 

Events

static EventCallback< GameServicesAuthStatusChangeResultOnAuthStatusChange
 Event called on local player auth change.
 

Detailed Description

Internally, game services feature uses native game servers for handling functionalities. So while running your game on iOS devices, Game Center servers will be used. Whereas on Android platform, Play Game Services server will be used.

Goto iTune's Connect to configure leaderboard, achievemnts for your iOS game. And for Android, add records at Google Developer Console.

Member Function Documentation

◆ Initialize()

◆ CreateLeaderboard()

static ILeaderboard CreateLeaderboard ( string leaderboardId)
static
Parameters
leaderboardIdA string used to uniquely identify the leaderboard.

Referenced by GameServices.ReportScore().

◆ LoadLeaderboards()

static void LoadLeaderboards ( EventCallback< GameServicesLoadLeaderboardsResult > callback)
static
Parameters
callbackCallback method that will be invoked after operation is completed.

◆ CreateAchievement()

static IAchievement CreateAchievement ( string achievementId)
static
Parameters
achievementIdA string used to uniquely identify the achievement.

Referenced by GameServices.ReportAchievementProgress(), and GameServices.ReportAchievementProgress().

◆ LoadAchievementDescriptions()

static void LoadAchievementDescriptions ( EventCallback< GameServicesLoadAchievementDescriptionsResult > callback)
static
Parameters
callbackCallback method that will be invoked after operation is completed.

◆ LoadAchievements()

static void LoadAchievements ( EventCallback< GameServicesLoadAchievementsResult > callback)
static
Parameters
callbackCallback method that will be invoked after operation is completed.

◆ ReportAchievementProgress() [1/3]

static void ReportAchievementProgress ( string achievementId,
double percentageCompleted,
CompletionCallback callback )
static
Parameters
achievementIdA string used to uniquely identify the achievement.
percentageCompletedThe value indicates how far the player has progressed.
callbackCallback that will be called after operation is completed.

References GameServices.CreateAchievement(), and GameServices.ReportAchievementProgress().

Referenced by GameServices.ReportAchievementProgress(), and GameServices.ReportAchievementProgress().

◆ ReportAchievementProgress() [2/3]

static void ReportAchievementProgress ( IAchievementDescription achievementDescription,
double percentageCompleted,
CompletionCallback callback )
static
Parameters
achievementDescriptionThe achievement description object.
percentageCompletedThe value indicates how far the player has progressed.
callbackCallback that will be called after operation is completed.

References GameServices.CreateAchievement(), IAchievementDescription.Id, and GameServices.ReportAchievementProgress().

◆ ReportAchievementProgress() [3/3]

static void ReportAchievementProgress ( IAchievement achievement,
double percentageCompleted,
CompletionCallback callback )
static
Parameters
achievementThe achievement object.
percentageCompletedThe value indicates how far the player has progressed.
callbackCallback that will be called after operation is completed.

References IAchievement.ReportProgress().

◆ LoadFriends()

static void LoadFriends ( EventCallback< GameServicesLoadPlayerFriendsResult > callback)
static
Parameters
callbackThe callback that will be called after operation is completed. If successful, it will contain the list of friends.

References GameServices.IsAuthenticated, ILocalPlayer.LoadFriends(), and GameServices.LocalPlayer.

◆ AddFriend()

static void AddFriend ( string playerId,
EventCallback< bool > callback )
static
Parameters
playerIdThe id of the player to send the request to.
callbackThe callback that will be called after operation is completed.

References ILocalPlayer.AddFriend(), GameServices.IsAuthenticated, and GameServices.LocalPlayer.

◆ ReportScore() [1/2]

static void ReportScore ( string leaderboardId,
long value,
CompletionCallback callback,
string tag = null )
static
Parameters
leaderboardIdA string used to uniquely identify the leaderboard.
valueThe value of the score.
callbackCallback that will be called after operation is completed.
tagThe tag used to identify the score (optional). This needs to be of max length 8 characters in ascii characters.

References GameServices.CreateLeaderboard(), and GameServices.ReportScore().

Referenced by GameServices.ReportScore().

◆ ReportScore() [2/2]

static void ReportScore ( ILeaderboard leaderboard,
long value,
CompletionCallback callback,
string tag = null )
static
Parameters
leaderboardThe leaderboard object.
valueThe value of the score.
callbackCallback that will be called after operation is completed.
tagThe tag used to identify the score (optional). This needs to be of max length 8 characters in ascii characters.

References ILeaderboard.ReportScore().

◆ ShowLeaderboards()

static void ShowLeaderboards ( LeaderboardTimeScope timescope = LeaderboardTimeScope::AllTime,
EventCallback< GameServicesViewResult > callback = null )
static
Parameters
timescopeA time filter used to restrict which scores are displayed to the player.
callbackCallback that will be called after operation is completed.

◆ ShowLeaderboard() [1/2]

static void ShowLeaderboard ( string leaderboardId,
LeaderboardTimeScope timescope = LeaderboardTimeScope::AllTime,
EventCallback< GameServicesViewResult > callback = null )
static
Parameters
leaderboardIdA string used to identify the leaderboard.
timescopeA time filter used to restrict which scores are displayed to the player.
callbackCallback that will be called after operation is completed.
Note
Incase, if you want to list out all the leaderboards that are used in your game, then pass null for leaderboard identifier.

◆ ShowLeaderboard() [2/2]

static void ShowLeaderboard ( ILeaderboard leaderboard,
LeaderboardTimeScope timescope = LeaderboardTimeScope::AllTime,
EventCallback< GameServicesViewResult > callback = null )
static
Parameters
leaderboardThe leaderboard object.
timescopeA time filter used to restrict which scores are displayed to the player.
callbackCallback that will be called after operation is completed.
Note
Incase, if you want to list out all the leaderboards that are used in your game, then pass null for leaderboard identifier.

References ILeaderboard.Id, and ILeaderboard.PlatformId.

◆ ShowAchievements()

static void ShowAchievements ( EventCallback< GameServicesViewResult > callback = null)
static
Parameters
callbackCallback that will be called after operation is completed.

◆ LoadServerCredentials()

static void LoadServerCredentials ( EventCallback< GameServicesLoadServerCredentialsResult > callback)
static
Parameters
callbackCallback that will be called after operation is completed.

The server credentials is a set of properties that can be used to connect to game service from your backend.

◆ LoadPlayers()

static void LoadPlayers ( string[] playerIds,
EventCallback< GameServicesLoadPlayersResult > callback )
static
Parameters
playerIdsAn array of player id's whose details has to be retrieved from game server.
callbackCallback that will be called after operation is completed.

◆ CreateScore() [1/2]

static IScore CreateScore ( string leaderboardId)
static
Returns
The score object.
Parameters
leaderboardIdA string used to uniquely identify the leaderboard.

◆ CreateScore() [2/2]

static IScore CreateScore ( ILeaderboard leaderboard)
static
Returns
The score object.
Parameters
leaderboardThe leaderboard object.

Property Documentation

◆ LocalPlayer

ILocalPlayer LocalPlayer
staticget

The local player.

Referenced by GameServices.AddFriend(), and GameServices.LoadFriends().

◆ IsAuthenticated

bool IsAuthenticated
staticget

true if is authenticated; otherwise, false.

Referenced by GameServices.AddFriend(), and GameServices.LoadFriends().

◆ Leaderboards

ILeaderboard [] Leaderboards
staticget
Note
This property is invalid until a call to LoadLeaderboards(EventCallback<GameServicesLoadLeaderboardsResult>) is completed.

Referenced by GameServices.Initialize().

◆ AchievementDescriptions

IAchievementDescription [] AchievementDescriptions
staticget
Note
This property is invalid until a call to LoadAchievementDescriptions(EventCallback<GameServicesLoadAchievementDescriptionsResult>) is completed.

Referenced by GameServices.Initialize().

◆ Achievements

IAchievement [] Achievements
staticget
Note
This property is invalid until a call to LoadAchievements(EventCallback<GameServicesLoadAchievementsResult>) is completed.

Referenced by GameServices.Initialize().