-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameCenterScript.cs
63 lines (52 loc) · 2.02 KB
/
GameCenterScript.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using UnityEngine;
using System.Collections;
using UnityEngine.SocialPlatforms.GameCenter;
using UnityEngine.SocialPlatforms;
public class GameCenterScript : MonoBehaviour {
// Use this for initialization
void Start () {
#if UNITY_IPHONE
Social.localUser.Authenticate(ProcessAuthentication);
#endif
#if UNITY_ANDROID
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
Social.localUser.Authenticate(ProcessAuthentication);
#endif
}
// Update is called once per frame
void Update () {
}
// This function gets called when Authenticate completes
// Note that if the operation is successful, Social.localUser will contain data from the server.
void ProcessAuthentication(bool success)
{
if (success)
{
Debug.Log("Authenticated, checking achievements");
// Request loaded achievements, and register a callback for processing them
//Social.LoadAchievements(ProcessLoadedAchievements);
Social.ShowLeaderboardUI();
}
else
Debug.Log("Failed to authenticate");
}
// This function gets called when the LoadAchievement call completes
void ProcessLoadedAchievements(IAchievement[] achievements)
{
if (achievements.Length == 0)
Debug.Log("Error: no achievements found");
else
Debug.Log("Got " + achievements.Length + " achievements");
//// You can also call into the functions like this
//Social.ReportProgress("Achievement01", 100.0, result =>
//{
// if (result)
// Debug.Log("Successfully reported achievement progress");
// else
// Debug.Log("Failed to report achievement");
//});
}
}