void ShowLoginUI() { OKLog.Info("Showing login UI"); OKManager.ShowLoginToOpenKitWithDismissCallback(() => { OKLog.Info("Finished showing OpenKit login window, in the callback"); }); }
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("OpenKit Demo Scene"); if (GUILayout.Button("Show Leaderboards & Achievements", h)) { ShowLeaderboards(); } if (GUILayout.Button("Show Single Leaderboard", h)) { // Instead of showing a list of leaderboards, show a single specified leaderboard ID OKManager.ShowLeaderboard(SampleLeaderboardID);; } if (GUILayout.Button("Show Login UI", h)) { ShowLoginUI(); } if (GUILayout.Button("Submit Score to Level 1 Leaderboard", h)) { SubmitSampleScore(); } if (GUILayout.Button("Unlock Achievement", h)) { UnlockSampleAchievement(); } if (GUILayout.Button("Logout from OpenKit", h)) { OKManager.LogoutCurrentUserFromOpenKit(); OKLog.Info("logout of OpenKit"); } if (GUILayout.Button("Get Leaderboards in C#", h)) { GetLeaderboards(); } if (GUILayout.Button("Get social scores", h)) { GetSocialScores(); } if (GUILayout.Button("Get my best score (in C#)", h)) { GetMyBestScore(); } GUILayout.EndArea(); }
void ShowLoginUI() { Action loginCallback = () => { Debug.Log("Finished showing OpenKit login UI"); }; OKManager.ShowLoginToOpenKitWithDismissCallback(loginCallback); }
void Setup() { // Authenticate the local player with GameCenter (iOS only). OKManager.authenticateGameCenterLocalPlayer(); // Listen for native openkit view events. OKManager.ViewWillAppear += ViewWillAppear; OKManager.ViewDidAppear += ViewDidAppear; OKManager.ViewWillDisappear += ViewWillDisappear; OKManager.ViewDidDisappear += ViewDidDisappear; }
void SetupOpenKit() { OKSettings.Load(); // AppKey and SecretKey are set in the OpenKit menu OKManager.Configure(OKSettings.AppKey, OKSettings.AppSecretKey); // If you want to disable the achievements UI, uncomment the line below //OKManager.SetAchievementsEnabled(false); // If you want to display a LeaderboardListTag other than the default "v1" tag, then // uncomment this line and set the tag //OKManager.SetLeaderboardListTag("v1"); // If you want to disable Google Login, uncomment the below line (Android only) //OKManager.SetGoogleLoginEnabled(false); }
void SetupOpenKit() { // Get your appKey and secretKey from the OpenKit developer dashboard. // The keys below are for the openkit sample app. string myAppKey = "BspfxiqMuYxNEotLeGLm"; string mySecretKey = "2sHQOuqgwzocUdiTsTWzyQlOy1paswYLGjrdRWWf"; // You must call OKManager.Configure(..) OKManager.Configure(myAppKey, mySecretKey); // If you want to disable the achievements UI, uncomment the line below //OKManager.SetAchievementsEnabled(false); // If you want to display a LeaderboardListTag other than the default "v1" tag, then // uncomment this line and set the tag //OKManager.SetLeaderboardListTag("v1"); // If you want to disable Google Login, uncomment the below line (Android only) //OKManager.SetGoogleLoginEnabled(false); }
void Setup() { // Authenticate the local player with GameCenter (iOS only). OKManager.authenticateGameCenterLocalPlayer(); // Listen for native openkit view events. OKManager.ViewWillAppear += ViewWillAppear; OKManager.ViewDidAppear += ViewDidAppear; OKManager.ViewWillDisappear += ViewWillDisappear; OKManager.ViewDidDisappear += ViewDidDisappear; if (OKManager.IsCurrentUserAuthenticated()) { OKLog.Info("Found OpenKit user"); } else { ShowLoginUI(); OKLog.Info("Did not find OpenKit user"); } }
// Use this for initialization void Start() { // This should be called at the beginning of your game. // The app key below is taken from your OpenKit Application Key in the OpenKit dashboard. OKManager.AppKey = "VwfMRAl5Gc4tirjw"; //Set the endpoint to something other than the default OKManager.Endpoint = "http://stage.openkit.io"; // This shows sample usage of checking whether the user is logged in OKUser currentUser = OKManager.GetCurrentUser(); if (currentUser != null) { Debug.Log("Logged into OpenKit as " + currentUser.userNick); } else { Debug.Log("Not logged into OpenKit"); } }
void OnGUI() { ///Scale the button sizes for retina displays float screenScale = (float)(Screen.width / 480.0); Matrix4x4 scaledMatrix = Matrix4x4.Scale(new Vector3(screenScale, screenScale, screenScale)); GUI.matrix = scaledMatrix; if (GUI.Button(new Rect(30, 10, 400, 100), "Show Leaderboards & Achievements")) { // Show leaderboards. // If the user is not logged into OpenKit, the login UI // will be shown ontop of the leaderboards OKManager.ShowLeaderboards(); } if (GUI.Button(new Rect(30, 120, 400, 100), "Show Login UI")) { // Show the OpenKit Login UI OKManager.ShowLoginToOpenKit(); } if (GUI.Button(new Rect(30, 230, 400, 100), "Submit Score to Level 3 Leaderboard")) { #if !UNITY_EDITOR // Submit a score to a leaderboard, with a value of 2134 to leaderboard ID 4 // If the user is not logged in, the score will not be submitted successfully string scoreString = "" + DateTime.Now.Month; scoreString += DateTime.Now.Day; scoreString += DateTime.Now.Hour; scoreString += DateTime.Now.Minute; long scoreValue = long.Parse(scoreString); OKScore score = new OKScore(scoreValue, 4); // Set the displayString to include the units of the score score.displayString = score.scoreValue + " points"; // Store some metadata in the score-- this is not used by OpenKit but is stored and returned with each score score.metadata = 1; score.submitScore(scoreSubmitHandler); #endif } if (GUI.Button(new Rect(30, 340, 400, 100), "Unlock Achievement")) { //Unlock achievement by setting its progress for the current user // to 5. The achievement ID is pulled from the OpenKit dashboard, // and we know that the target goal of the achievement is also 5 which is set in the dashboard, // so this unlocks the achievement OKAchievementScore achievementScore = new OKAchievementScore(5, 3); achievementScore.submitAchievementScore(achievementScoreSubmitHandler); } if (GUI.Button(new Rect(30, 450, 400, 100), "Store dictionary")) { //Store a dictionary ArrayList y = new ArrayList(); y.Add("First element."); y.Add("Second!"); Dictionary <string, object> x = new Dictionary <string, object>(); x.Add("prop1", "YEAAAAAAH BUDDY."); x.Add("prop2", 99); x.Add("prop3", y); // Cloud store. OKCloud.Set(x, "aKey", delegate(object obj, OKCloudException err) { if (err == null) { OKLog.Info("Stored object of type: " + obj.GetType().Name); } else { OKLog.Info("Error during store: " + err); } }); } if (GUI.Button(new Rect(30, 560, 400, 100), "Retrieve dictionary")) { //Retrieve the dictionary OKCloud.Get("aKey", delegate(JSONObject obj, OKCloudException err) { if (err == null) { OKLog.Info("Retrieved object of type: " + obj.GetType().Name); OKLog.Info("Obj: " + obj); OKLog.Info("Can I get an element of an Array? " + obj.GetField("prop3")[1]); } else { OKLog.Info("Error during store: " + err); } }); } }
private void NativeViewDidDisappear(string empty) { OKManager.HandleNativeEvent(this, OKNativeEvent.viewDidDisappear); }
void ShowAchievements() { OKManager.ShowAchievements(); }
void ShowLeaderboards() { OKManager.ShowLeaderboards(); }
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("OpenKit Demo Scene"); if (GUILayout.Button("Show Leaderboards", h)) { ShowLeaderboards(); } if (GUILayout.Button("Show Achievements", h)) { ShowAchievements(); } if (GUILayout.Button("Show Single Leaderboard", h)) { // Instead of showing a list of leaderboards, show a single specified leaderboard ID OKManager.ShowLeaderboard(SampleLeaderboardID);; } if (GUILayout.Button("Show Leaderboards & Achievements", h)) { OKManager.ShowLeaderboardsAndAchivements(); } if (GUILayout.Button("Show Login UI", h)) { ShowLoginUI(); } if (GUILayout.Button("Submit Score to Level 1 Leaderboard", h)) { SubmitSampleScore(); } if (GUILayout.Button("Unlock Achievement", h)) { UnlockSampleAchievement(); } if (GUILayout.Button("Logout from OpenKit", h)) { OKManager.LogoutCurrentUserFromOpenKit(); OKLog.Info("logout of OpenKit"); } if (GUILayout.Button("Get Leaderboards and global scores in C#", h)) { GetLeaderboards(); } if (GUILayout.Button("Get my best score (in C#)", h)) { GetMyBestScore(); } if (GUILayout.Button("Get friends scores in C#", h)) { GetSocialScores(); } /* * if(GUILayout.Button("FB SDK Test",h)) { * * if(FB.IsLoggedIn) { * GetFBInfo(); * return; * } * * FB.Init(() => { * OKLog.Info("FB Init called"); * * if(FB.IsLoggedIn) { * OKLog.Info("logged into FB in Unity"); * GetFBInfo(); * } else { * OKLog.Info("not logged into FB unity"); * FB.Login("email",(FBResult result) => { * OKLog.Info("Result of calling fb login: "******"Get scores with metadata", h)) { GetScoresWithMetadata(); } GUILayout.EndArea(); }
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(); }