Class GameServices
Inheritance
Namespace: EasyMobile
Assembly: cs.temp.dll.dll
Syntax
public class GameServices : MonoBehaviour
Properties
Instance
Declaration
public static GameServices Instance { get; }
Property Value
Type | Description |
---|---|
GameServices |
LocalUser
The local or currently logged in user. Returns null if the user has not logged in.
Declaration
public static ILocalUser LocalUser { get; }
Property Value
Type | Description |
---|---|
ILocalUser | The local user. |
Methods
GetAchievementByName(String)
Returns an achievement it one with an achievementName was declared before within achievements array.
Declaration
public static Achievement GetAchievementByName(string achievementName)
Parameters
Type | Name | Description |
---|---|---|
System.String | achievementName | Achievement name. |
Returns
Type | Description |
---|---|
Achievement | The achievement by name. |
GetAnotherServerAuthCode(Boolean, Action<String>)
[Google Play Games] Gets another server auth code.
Declaration
public static void GetAnotherServerAuthCode(bool reAuthenticateIfNeeded, Action<string> callback)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | reAuthenticateIfNeeded | |
System.Action<System.String> | callback |
GetLeaderboardByName(String)
Returns a leaderboard it one with a leaderboardName was declared before within leaderboards array.
Declaration
public static Leaderboard GetLeaderboardByName(string leaderboardName)
Parameters
Type | Name | Description |
---|---|---|
System.String | leaderboardName | Leaderboard name. |
Returns
Type | Description |
---|---|
Leaderboard | The leaderboard by name. |
GetServerAuthCode()
[Google Play Games] Gets the server auth code.
Declaration
public static string GetServerAuthCode()
Returns
Type | Description |
---|---|
System.String |
Init()
Initializes the service. This is required before any other actions can be done e.g reporting scores. During the initialization process, a login popup will show up if the user hasn't logged in, otherwise the process will carry on silently. Note that on iOS, the login popup will show up automatically when the app gets focus for the first 3 times while subsequent authentication calls will be ignored.
Declaration
public static void Init()
IsInitialized()
Determines whether this module is initialized (user is authenticated) and ready to use.
Declaration
public static bool IsInitialized()
Returns
Type | Description |
---|---|
System.Boolean |
|
LoadFriends(Action<IUserProfile[]>)
Loads all friends of the authenticated user. Internally it will populate the LocalUsers.friends array and invoke the callback with this array if the loading succeeded. If the loading failed, the callback will be invoked with an empty array. If the LocalUsers.friends array is already populated then the callback will be invoked immediately without any loading request being made.
Declaration
public static void LoadFriends(Action<IUserProfile[]> callback)
Parameters
Type | Name | Description |
---|---|---|
System.Action<IUserProfile[]> | callback | Callback. |
LoadLocalUserScore(String, Action<String, IScore>)
Loads the local user's score from the specified leaderboard. Note that each load score request is added into a queue and the next request is called after the callback of previous request has been invoked.
Declaration
public static void LoadLocalUserScore(string leaderboardName, Action<string, IScore> callback)
Parameters
Type | Name | Description |
---|---|---|
System.String | leaderboardName | Leaderboard name. |
System.Action<System.String, IScore> | callback | Callback receives the leaderboard name and the loaded score. |
LoadScores(String, Action<String, IScore[]>)
Loads a set of scores using the default parameters of the given leaderboard. This returns the 25 scores that are around the local player's score in the Global userScope and AllTime timeScope. Note that each load score request is added into a queue and the next request is called after the callback of previous request has been invoked.
Declaration
public static void LoadScores(string leaderboardName, Action<string, IScore[]> callback)
Parameters
Type | Name | Description |
---|---|---|
System.String | leaderboardName | Leaderboard name. |
System.Action<System.String, IScore[]> | callback | Callback receives the leaderboard name and an array of loaded scores. |
LoadScores(String, Int32, Int32, TimeScope, UserScope, Action<String, IScore[]>)
Loads the set of scores from the specified leaderboard within the specified timeScope and userScope. The range is defined by starting position fromRank and the number of scores to retrieve scoreCount. Note that each load score request is added into a queue and the next request is called after the callback of previous request has been invoked.
Declaration
public static void LoadScores(string leaderboardName, int fromRank, int scoreCount, TimeScope timeScope, UserScope userScope, Action<string, IScore[]> callback)
Parameters
Type | Name | Description |
---|---|---|
System.String | leaderboardName | Leaderboard name. |
System.Int32 | fromRank | The rank of the first score to load. |
System.Int32 | scoreCount | The total number of scores to load. |
TimeScope | timeScope | Time scope. |
UserScope | userScope | User scope. |
System.Action<System.String, IScore[]> | callback | Callback receives the leaderboard name and an array of loaded scores. |
LoadUsers(String[], Action<IUserProfile[]>)
Loads the user profiles associated with the given array of user IDs.
Declaration
public static void LoadUsers(string[] userIds, Action<IUserProfile[]> callback)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | userIds | User identifiers. |
System.Action<IUserProfile[]> | callback | Callback. |
ManagedInit()
Internally calls the Init() method. If the user hasn't logged in to the service, a login UI will popup. Otherwise, it will initialize silently. On iOS, the OS automatically shows the login popup when the app gets focus for the first 3 times. Subsequent init calls will be ignored. On Android, if the user dismisses the login popup for a number of times determined by AndroidMaxLoginRequests, we'll stop showing it (all subsequent init calls will be ignored).
Declaration
public static void ManagedInit()
ReportAchievementProgress(String, Double, Action<Boolean>)
Reports the progress of the incremental achievement with the specified name.
Declaration
public static void ReportAchievementProgress(string achievementName, double progress, Action<bool> callback = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | achievementName | Achievement name. |
System.Double | progress | Progress. |
System.Action<System.Boolean> | callback | Callback receives a |
ReportScore(Int64, String, Action<Boolean>)
Reports the score to the leaderboard with the given name.
Declaration
public static void ReportScore(long score, string leaderboardName, Action<bool> callback = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | score | Score. |
System.String | leaderboardName | Leaderboard name. |
System.Action<System.Boolean> | callback | Callback receives a |
RevealAchievement(String, Action<Boolean>)
Reveals the hidden achievement with the specified name.
Declaration
public static void RevealAchievement(string achievementName, Action<bool> callback = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | achievementName | Achievement name. |
System.Action<System.Boolean> | callback | Callback receives a |
ShowAchievementsUI()
Shows the achievements UI.
Declaration
public static void ShowAchievementsUI()
ShowLeaderboardUI()
Shows the leaderboard UI.
Declaration
public static void ShowLeaderboardUI()
ShowLeaderboardUI(String)
Shows the leaderboard UI for the given leaderboard.
Declaration
public static void ShowLeaderboardUI(string leaderboardName)
Parameters
Type | Name | Description |
---|---|---|
System.String | leaderboardName | Leaderboard name. |
ShowLeaderboardUI(String, TimeScope)
Shows the leaderboard UI for the given leaderboard in the specified time scope.
Declaration
public static void ShowLeaderboardUI(string leaderboardName, TimeScope timeScope)
Parameters
Type | Name | Description |
---|---|---|
System.String | leaderboardName | Leaderboard name. |
TimeScope | timeScope | Time scope to display scores in the leaderboard. |
SignOut()
[Google Play Games] Signs the user out.
Declaration
public static void SignOut()
UnlockAchievement(String, Action<Boolean>)
Unlocks the achievement with the specified name.
Declaration
public static void UnlockAchievement(string achievementName, Action<bool> callback = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | achievementName | Achievement name. |
System.Action<System.Boolean> | callback | Callback receives a |
Events
UserLoginFailed
Occurs when user login failed.
Declaration
public static event Action UserLoginFailed
Event Type
Type | Description |
---|---|
System.Action |
UserLoginSucceeded
Occurs when user login succeeded.
Declaration
public static event Action UserLoginSucceeded
Event Type
Type | Description |
---|---|
System.Action |