diff --git a/Samples/SmokeTest/Scripts/MainGui.cs b/Samples/SmokeTest/Scripts/MainGui.cs index d1c27e60..f815fc82 100644 --- a/Samples/SmokeTest/Scripts/MainGui.cs +++ b/Samples/SmokeTest/Scripts/MainGui.cs @@ -59,6 +59,7 @@ public class MainGui : MonoBehaviour private AchievementGUI mAchievementGui; private LeaderboardGUI mLeaderboardGui; private FriendsGUI mFriendsGui; + private RecallGUI mRecallGui; // which UI are we showing? public enum Ui { @@ -72,7 +73,8 @@ public enum Ui { Achievements, Leaderboards, UserInfo, - Friends + Friends, + Recall } public void Start() @@ -86,6 +88,7 @@ public void Start() this.mAchievementGui = new AchievementGUI(this); this.mLeaderboardGui = new LeaderboardGUI(this); this.mFriendsGui = new FriendsGUI(this); + this.mRecallGui = new RecallGUI(this); } public void SetUI(Ui page) @@ -196,6 +199,10 @@ internal void ShowRegularUi() { SetUI(Ui.Events); } + else if (GUI.Button(this.CalcGrid(1, 4), "Recall")) + { + SetUI(Ui.Recall); + } } internal void ShowEditSavedGameName() @@ -660,6 +667,9 @@ internal void OnGUI() case Ui.UserInfo: ShowUserInfoUi(); break; + case Ui.Recall: + mRecallGui.OnGUI(); + break; default: // check for a status of interest, and if there // is one, then don't touch it. Otherwise diff --git a/Samples/SmokeTest/Scripts/RecallGUI.cs b/Samples/SmokeTest/Scripts/RecallGUI.cs new file mode 100644 index 00000000..af31fc4f --- /dev/null +++ b/Samples/SmokeTest/Scripts/RecallGUI.cs @@ -0,0 +1,89 @@ +// +// Copyright (C) 2014 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace SmokeTest +{ + using UnityEngine; + using GooglePlayGames; + + public class RecallGUI : MonoBehaviour + { + private MainGui mOwner; + private string mStatus; + + internal RecallGUI(MainGui owner) + { + mOwner = owner; + mStatus = ""; + } + + internal void OnGUI() + { + float height = Screen.height / 11f; + GUILayout.BeginVertical(GUILayout.Height(Screen.height), GUILayout.Width(Screen.width)); + GUILayout.Label("SmokeTest: Recall", GUILayout.Height(height)); + GUILayout.BeginHorizontal(GUILayout.Height(height)); + if (GUILayout.Button("Get Recall Access Token", GUILayout.Height(height), GUILayout.ExpandWidth(true))) + { + GetRecallAccessToken(); + } + GUILayout.EndHorizontal(); + GUILayout.Space(50f); + GUILayout.BeginHorizontal(GUILayout.Height(height)); + + if (GUILayout.Button("Back", GUILayout.ExpandHeight(true), + GUILayout.Height(height), GUILayout.ExpandWidth(true))) + { + mOwner.SetUI(MainGui.Ui.Main); + } + + GUILayout.EndHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.Label(mStatus); + GUILayout.EndVertical(); + } + + void SetStandBy(string msg) + { + mStatus = msg; + } + + void EndStandBy() + { + mStatus += " (Done!)"; + } + + internal void ShowEffect(bool success) + { + Camera.main.backgroundColor = + success ? new Color(0.0f, 0.0f, 0.8f, 1.0f) : new Color(0.8f, 0.0f, 0.0f, 1.0f); + } + + internal void GetRecallAccessToken() + { + SetStandBy("Fetching recall access token......"); + PlayGamesPlatform.Instance.RequestRecallAccess( + recallAccess => { + EndStandBy(); + string recallSessionId = recallAccess.sessionId; + mStatus = "Recall Session ID for current session is: " + recallSessionId; + Debug.Log("Recall Token fetched successfully: " + mStatus); + ShowEffect(recallSessionId != null && recallSessionId != ""); + }); + return; + } + } +} \ No newline at end of file