private IEnumerator SendStartMessageCoroutine() { int count = 0; while (!isStartMessageReceived) { if (count < startMessageLimit) { stopwatch.Reset(); stopwatch.Start(); SendStartGameMessage(); count++; yield return(new WaitForSeconds(startMessageInterval)); } else { string title = "No Reponse"; string message = "There is no reponse from your opponent. You can click the \"Back\" button in the header to leave the match."; NativeUI.Alert(title, message); yield break; } } }
public override void OnEnter() { if (string.IsNullOrEmpty(label.Value)) { NativeUI.Alert("Invalid email label", "Email's label can't be empty"); Finish(); } if (string.IsNullOrEmpty(email.Value)) { NativeUI.Alert("Invalid email", "Email can't be empty"); Finish(); } AddedEmailsObject temp = (AddedEmailsObject)emailsObject.Value; List <StringStringKeyValuePair> addedEmails = temp.AddedEmails; if (addedEmails == null) { addedEmails = new List <StringStringKeyValuePair>(); } addedEmails.Add(new StringStringKeyValuePair(label.Value, email.Value)); temp.AddedEmails = addedEmails; emailsObjectOut.Value = temp; emailsObject.Value = temp; NativeUI.Alert("Success", "New email has been added."); Finish(); }
public void ReadSavedGame() { if (selectedSavedGame == null) { NativeUI.Alert("Alert", "Please select a saved game by using the select UI or entering its name into the input box."); return; } else { if (selectedSavedGame.IsOpen) { GameServices.SavedGames.ReadSavedGameData(selectedSavedGame, OnSavedGameRead); } else { DoOpenSavedGame(selectedSavedGame.Name, (SavedGame game, string error) => { if (string.IsNullOrEmpty(error)) { selectedSavedGame = game; GameServices.SavedGames.ReadSavedGameData(selectedSavedGame, OnSavedGameRead); } else { NativeUI.Alert("Alert", "Couldn't read saved game data because it's failed to open with error: " + error); } }); } } }
public void DeleteSavedGame() { if (selectedSavedGame == null) { NativeUI.Alert("Alert", "Please select a saved game by using the select UI or entering its name into the input box."); return; } else { NativeUI.AlertPopup alert = NativeUI.ShowTwoButtonAlert( "Delete Saved Game?", "Do you want to delete the saved game '" + selectedSavedGame.Name + "'?", "Yes", "No"); if (alert != null) { alert.OnComplete += (int button) => { if (button == 0) { GameServices.SavedGames.DeleteSavedGame(selectedSavedGame); selectedSavedGame = null; NativeUI.Alert("Alert", "Saved game deleted!"); } }; } } }
public void FetchAllSavedGames() { GameServices.SavedGames.FetchAllSavedGames((SavedGame[] games, string error) => { if (string.IsNullOrEmpty(error)) { allSavedGames = games; var items = new Dictionary <string, string>(); foreach (SavedGame game in allSavedGames) { #if UNITY_IOS items.Add(game.Name, game.DeviceName + " " + game.ModificationDate.ToString("d")); #else items.Add(game.Name, game.ModificationDate.ToString("d")); #endif } var scrollableList = ScrollableList.Create(scrollableListPrefab, "ALL SAVED GAMES", items); scrollableList.ItemSelected += OnSavedGameSelectedFromScrollableList; } else { NativeUI.Alert("Alert", "Fetch all saved games failed with error: " + error); } }); }
public void OnRoomConnected(bool success) { Debug.Log("[OnRoomConnected]. Success: " + success); if (IsDestroyed) { Debug.Log("[OnRoomConnected] Stop because IsDestroyed is true"); return; } createQuickMatchRequest--; if (createQuickMatchRequest <= 0) { StopCreateQuickMatchSpinningUI(); } if (!success) { NativeUI.Alert("Error", "Room connection failed."); LeaveRoom(); return; } StartGame(); }
public void UploadGIFToGiphy() { if (isExportingGif) { NativeUI.Alert("Exporting In Progress", "Please wait until the GIF exporting is completed."); return; } else if (string.IsNullOrEmpty(exportedGifPath)) { NativeUI.Alert("No Exported GIF", "Please export a GIF file first."); return; } isUploadingGif = true; var content = new GiphyUploadParams(); content.localImagePath = exportedGifPath; content.tags = "demo, easy mobile, sglib games, unity3d"; if (!string.IsNullOrEmpty(giphyUsername) && !string.IsNullOrEmpty(giphyApiKey)) { Giphy.Upload(giphyUsername, giphyApiKey, content, OnGiphyUploadProgress, OnGiphyUploadCompleted, OnGiphyUploadFailed); } else #if UNITY_EDITOR { Debug.LogError("Upload failed: please provide valid Giphy username and API key in the GifDemo game object."); } #else { NativeUI.Alert("Upload Failed", "Please provide valid Giphy username and API key in the GifDemo game object."); } #endif }
public void OpenSavedGame() { if (string.IsNullOrEmpty(savedGameNameInput.text)) { NativeUI.Alert("Alert", "Please enter a saved game name."); } else { string name = savedGameNameInput.text; DoOpenSavedGame(name, (SavedGame game, string error) => { selectedSavedGame = game; if (string.IsNullOrEmpty(error)) { NativeUI.Alert("Alert", "Saved game: " + game.Name + " is opened."); } else { NativeUI.Alert("Alert", "Saved game opening failed with error: " + error); } }); } }
private static void DemoDialog_Completed(ConsentDialog dialog, ConsentDialog.CompletedResults results) { Debug.Log("Demo consent dialog completed with button ID: " + results.buttonId); // Construct the new consent. DemoAppConsent newConsent = new DemoAppConsent(); if (results.toggleValues != null) { Debug.Log("Consent toggles:"); foreach (KeyValuePair <string, bool> t in results.toggleValues) { string toggleId = t.Key; bool toggleValue = t.Value; Debug.Log("Toggle ID: " + toggleId + "; Value: " + toggleValue); if (toggleId == AdsToggleId) { // Whether the Advertising module is given consent. newConsent.advertisingConsent = toggleValue ? ConsentStatus.Granted : ConsentStatus.Revoked; } else if (toggleId == NotifsToggleId) { // Whether the Notifications module is given consent. newConsent.notificationConsent = toggleValue ? ConsentStatus.Granted : ConsentStatus.Revoked; } else if (toggleId == UnityAnalyticsToggleId) { // We don't store the UnityAnalytics consent ourselves as it is managed // by the Unity Data Privacy plugin. } else { // Unrecognized toggle ID. } } } Debug.Log("Now forwarding new consent to relevant modules and then store it..."); // Forward the consent to relevant modules. DemoAppConsent.ApplyDemoAppConsent(newConsent); // Store the new consent. DemoAppConsent.SaveDemoAppConsent(newConsent); // So now we have applied the consent, we can initialize EM runtime // (as well as other 3rd-party SDKs in a real-world app). if (!RuntimeManager.IsInitialized()) { RuntimeManager.Init(); } else { // The initialization has already been done. Inform the user // that the changes will take effect during next initialization (next app launch). NativeUI.Alert("Consent Updated", "You've updated your data privacy consent. " + "Since the initialization process has already completed, all changes will take effect in the next app launch."); } }
public void ReportScore() { if (!GameServices.IsInitialized()) { NativeUI.Alert("Alert", "You need to initialize the module first."); return; } if (selectedLeaderboard == null) { NativeUI.Alert("Alert", "Please select a leaderboard to report score to."); } else { if (string.IsNullOrEmpty(scoreInput.text)) { NativeUI.Alert("Alert", "Please enter a score to report."); } else { int score = System.Convert.ToInt32(scoreInput.text); GameServices.ReportScore(score, selectedLeaderboard.Name); NativeUI.Alert("Alert", "Reported score " + score + " to leaderboard \"" + selectedLeaderboard.Name + "\"."); } } }
void Update() { // Check if autoInit is on. if (EM_Settings.GameServices.IsAutoInit) { demoUtils.DisplayBool(isAutoInitInfo, true, "Auto Initialization: ON"); } else { demoUtils.DisplayBool(isAutoInitInfo, false, "Auto Initialization: OFF"); } // Check if the module is initalized. if (GameServices.IsInitialized()) { demoUtils.DisplayBool(isInitializedInfo, true, "User Logged In: TRUE"); } else { demoUtils.DisplayBool(isInitializedInfo, false, "User Logged In: FALSE"); if (lastLoginState) { NativeUI.Alert("User Logged Out", "User has logged out."); } } lastLoginState = GameServices.IsInitialized(); }
public void UploadGIFToGiphy() { if (isExportingGif) { NativeUI.Alert("Exporting In Progress", "Please wait until the GIF exporting is completed."); return; } else if (string.IsNullOrEmpty(exportedGifPath)) { NativeUI.Alert("No Exported GIF", "Please export a GIF file first."); return; } isUploadingGif = true; var content = new GiphyUploadParams(); content.localImagePath = exportedGifPath; content.tags = "demo, easy mobile, sglib games, unity3d"; if (!string.IsNullOrEmpty(giphyUsername) && !string.IsNullOrEmpty(giphyApiKey)) { Giphy.Upload(giphyUsername, giphyApiKey, content, OnGiphyUploadProgress, OnGiphyUploadCompleted, OnGiphyUploadFailed); } else { Giphy.Upload(content, OnGiphyUploadProgress, OnGiphyUploadCompleted, OnGiphyUploadFailed); } }
public void OnPeersDisconnected(string[] participantIds) { if (IsDestroyed) { return; } if (participantIds == null) { NativeUI.Alert("On Peers Disconnected", "Received a null \"participantIds\"."); return; } var message = "Disconnected Participant(s):\n"; for (int i = 0; i < participantIds.Length; i++) { var participant = GetParticipant(participantIds[i]); if (participant != null) { message += "\n" + GetParticipantDisplayString(participant); } else { message += "\nID: " + participantIds[i]; } } NativeUI.Alert("On Peers Disconnected", message); Debug.Log("[OnPeersDisconnected]. " + message); UpdateTargetParticipantDrowdown(); }
public override void OnEnter() { if (string.IsNullOrEmpty(label.Value)) { NativeUI.Alert("Invalid phone number's label", "Phone number's label can't be empty"); Finish(); return; } if (string.IsNullOrEmpty(phoneNumber.Value)) { NativeUI.Alert("Invalid phone number", "Phone number can't be empty"); Finish(); return; } AddedPhoneNumbersObject temp = (AddedPhoneNumbersObject)phoneNumbersObject.Value; List <StringStringKeyValuePair> addedPhoneNumbers = temp.AddedPhoneNumbers; if (addedPhoneNumbers == null) { addedPhoneNumbers = new List <StringStringKeyValuePair>(); } addedPhoneNumbers.Add(new StringStringKeyValuePair(label.Value, phoneNumber.Value)); temp.AddedPhoneNumbers = addedPhoneNumbers; phoneNumbersObjectOut.Value = temp; phoneNumbersObject.Value = temp; NativeUI.Alert("Success", "New phone number has been added."); Finish(); }
public void ShowRequestTrackingAuthorizationPopup() { Privacy.AppTrackingManager.RequestTrackingAuthorization(status => { NativeUI.Alert("Request Tracking Completed", "Tracking authorization request completed with result: " + status.ToString()); }); }
IEnumerator CRWaitAndShowPopup(bool hasNewUpdate, string title, string message) { // Wait until no other alert is showing. while (NativeUI.IsShowingAlert()) { yield return(new WaitForSeconds(0.1f)); } if (!hasNewUpdate) { NativeUI.Alert(title, message); } else { NativeUI.AlertPopup alert = NativeUI.ShowTwoButtonAlert( title, message, "Yes", "No"); if (alert != null) { alert.OnComplete += (int button) => { if (button == 0) { NativeUI.Alert( "Open App Store", "The user has opted to update! In a real app you would want to open the app store for them to download the new version."); } }; } } }
protected override void CreateWithMatchmaker() { GameServices.TurnBased.CreateWithMatchmakerUI( MatchRequest, () => { }, error => NativeUI.Alert("Error", "Failed to create a match with MatchMakerUI. Error: " + error)); }
public void GifDemo() { #if EASY_MOBILE_PRO SceneManager.LoadScene("GifDemo"); #else NativeUI.Alert("Feature Unavailable", "GIF feature is only available on Easy Mobile Pro."); #endif }
public void AcceptFromInbox() { #if UNITY_IOS NativeUI.Alert("Unsupported Feature", "\"Accept From Inbox\" feature is not available on Game Center platform"); #else GameServices.RealTime.ShowInvitationsUI(this); #endif }
public void GameServiceDemo_SavedGames() { #if EASY_MOBILE_PRO SceneManager.LoadScene("GameServicesDemo_SavedGames"); #else NativeUI.Alert("Feature Unavailable", "Saved Games feature is only available on Easy Mobile Pro."); #endif }
public void GameServiceDemo_Multiplayer_TicTacToe() { #if EASY_MOBILE_PRO SceneManager.LoadScene("GameServicesDemo_Multiplayer_TicTacToe"); #else NativeUI.Alert("Feature Unavailable", "Multiplayer feature is only available on Easy Mobile Pro."); #endif }
public void GameServiceDemo_Multiplayer_TurnbasedKitchensink() { #if EASY_MOBILE_PRO SceneManager.LoadScene("GameServicesDemo_Multiplayer_TurnBasedKitchenSink"); #else NativeUI.Alert("Feature Unavailable", "Multiplayer feature is only available on Easy Mobile Pro."); #endif }
public void ShowToast() { #if UNITY_ANDROID NativeUI.ShowToast("This is a sample Android toast"); #else NativeUI.Alert("Alert", "Toasts are available on Android only."); #endif }
public void ShowOneButtonAlert() { NativeUI.AlertPopup alert = NativeUI.Alert("Sample Alert", "This is a simple (1-button) alert."); if (alert != null) { alert.OnComplete += OnAlertComplete; } }
private Action <bool> GetAlertCallbackAction(string successMessage, string failedMessage) { return(success => { var title = success ? "Success" : "Fail"; NativeUI.Alert(title, success ? successMessage : failedMessage); }); }
public void NativeAPIsDemo_Contacts() { #if EASY_MOBILE_PRO SceneManager.LoadScene("ContactsDemo"); #else NativeUI.Alert("Feature Unavailable", "Contacts feature is only available on Easy Mobile Pro."); #endif }
IEnumerator CRSaveScreenshot() { yield return(new WaitForEndOfFrame()); TwoStepScreenshotPath = Sharing.SaveScreenshot(TwoStepScreenshotName); NativeUI.Alert("Alert", "A new screenshot was saved at " + TwoStepScreenshotPath); }
private void CheckAndPlayMatch(TurnBasedMatch match, bool playerWantsToQuit) { if (match.Data != null && match.Data.Length > 0 && MatchData.FromByteArray(match.Data) == null) { NativeUI.Alert("Error", "The arrived match can't be opened in this scene. You might want to open it in the TicTacToe demo instead."); return; } CurrentMatch = match; CurrentOpponents = CurrentMatch.Participants.Where(p => p.ParticipantId != CurrentMatch.SelfParticipantId).ToArray(); RefreshParticipantsDropDown(); canTakeTurn = true; if (CurrentMatch.Data == null || CurrentMatch.Data.Length < 1) /// New game detected... { CurrentMatchData = new MatchData() { TurnCount = 0 } } ; else { CurrentMatchData = MatchData.FromByteArray(CurrentMatch.Data); } if (CurrentMatch.Status == TurnBasedMatch.MatchStatus.Ended) { canTakeTurn = false; var result = string.Format("Winner: {0}\nTurnCount: {1}\n\n", CurrentMatchData.WinnerName ?? "null", CurrentMatchData.TurnCount); NativeUI.Alert("Finished Match Arrived", result + MatchFinishedMessage + "\n\nMatch info:\n" + GetTurnbasedMatchDisplayString(CurrentMatch)); return; } else if (CurrentMatch.Status == TurnBasedMatch.MatchStatus.Cancelled) { NativeUI.Alert("Cancelled Match Arrived", CancelledMatchMessage); return; } else if (CurrentMatch.Status == TurnBasedMatch.MatchStatus.Deleted) { NativeUI.Alert("Deleted Match Arrived", DeletedMatchMessage); return; } else if (CurrentMatch.Status == TurnBasedMatch.MatchStatus.Expired) { NativeUI.Alert("Expired Match Arrived", ExpiredMatchMessage); return; } if (AllOpponensLeft) { NativeUI.Alert("Game Over", AllOpponentsLeftMessage); return; } CurrentMatchData.TurnCount++; NativeUI.Alert("Match Arrived", "New match data has been arrived:\n" + GetTurnbasedMatchDisplayString(match)); }
void OnPurchaseCompleted(IAPProduct product) { if (!ownedProducts.Contains(product)) { ownedProducts.Add(product); } NativeUI.Alert("Purchased Completed", "The purchase of product " + product.Name + " has completed successfully. This is when you should grant the buyer digital goods."); }
IEnumerator CROnRestoreCompleted() { while (NativeUI.IsShowingAlert()) { yield return(new WaitForSeconds(0.5f)); } NativeUI.Alert("Restore Completed", "Your purchases have been restored successfully."); }