예제 #1
0
    // Get the list of leaderboards in C# (native unity)
    void GetLeaderboards()
    {
        OKLeaderboard.GetLeaderboards((List <OKLeaderboard> leaderboards, OKException exception) => {
            if (leaderboards != null)
            {
                OKLog.Info("Received " + leaderboards.Count + " leaderboards ");

                OKLeaderboard leaderboard = (OKLeaderboard)leaderboards[0];

                OKLog.Info("Getting scores for leaderboard ID: " + leaderboard.LeaderboardID + " named: " + leaderboard.Name);
                leaderboard.GetGlobalScores(1, (List <OKScore> scores, OKException exception2) => {
                    if (exception2 == null)
                    {
                        OKLog.Info("Got global scores in the callback");
                    }
                });
            }
            else
            {
                OKLog.Info("Error getting leaderboards");
            }
        });
    }
예제 #2
0
    void OnGUI()
    {
#if !UNITY_EDITOR
        GUI.matrix = GetScaleMatrix();
#endif
        Rect area = (IsPortraitOrientation() ? new Rect(0, 0, 320, 480) : new Rect(0, 0, 480, 320));
        GUILayout.BeginArea(area);
        GUILayoutOption h = GUILayout.Height(35);

        GUILayout.Label("Testing OpenKit...");

        if (GUILayout.Button("Show Leaderboards & Achievements", h))
        {
            ShowLeaderboards();
        }

        if (GUILayout.Button("Show Leaderboards Landscape Only (iOS)", h))
        {
            // For Android, to show Leaderboards landscape only you simply need to modify the AndroidManifest.xml file
            OKManager.ShowLeaderboardsLandscapeOnly();
        }

        if (GUILayout.Button("Show Login UI", h))
        {
            ShowLoginUI();
        }

        if (GUILayout.Button("Submit Score to Level 2 Leaderboard", h))
        {
            SubmitSampleScore();
        }

        if (GUILayout.Button("Unlock Achievement", h))
        {
            UnlockSampleAchievement();
        }

        if (GUILayout.Button("Store dictionary", h))
        {
            StoreSampleDictionary();
        }

        if (GUILayout.Button("Retrieve Dictionary", h))
        {
            RetrieveSampleDictionary();
        }


        if (GUILayout.Button("Logout from OpenKit", h))
        {
            OKManager.LogoutCurrentUserFromOpenKit();
            OKLog.Info("logout of OpenKit");
        }

        if (GUILayout.Button("Get Leaderboards", h))
        {
            OKLeaderboard.GetLeaderboards((List <OKLeaderboard> leaderboards, OKException exception) => {
                if (leaderboards != null)
                {
                    Debug.Log("Received " + leaderboards.Count + " leaderboards ");

                    OKLeaderboard leaderboard = (OKLeaderboard)leaderboards[0];

                    Debug.Log("Getting scores for leaderboard ID: " + leaderboard.LeaderboardID + " named: " + leaderboard.Name);
                    leaderboard.GetGlobalScores(1, (List <OKScore> scores, OKException exception2) => {
                        if (exception2 == null)
                        {
                            Debug.Log("Got global scores in the callback");
                        }
                    });
                }
                else
                {
                    Debug.Log("Error getting leaderboards");
                }
            });
        }

        if (GUILayout.Button("Get social scores Friends", h))
        {
            GetSocialScores();
        }

        if (GUILayout.Button("Get my best score!", h))
        {
            GetMyBestScore();
        }

        GUILayout.EndArea();
    }