// This callback is called once the GIF exporting has completed. // It receives the filepath of the generated image. void OnGifExportCompleted(AnimatedClip clip, string path) { progressText.text = "DONE"; isExportingGif = false; exportedGifPath = path; #if UNITY_EDITOR bool shouldUpload = UnityEditor.EditorUtility.DisplayDialog("Export Completed", "A GIF file has been created. Do you want to upload it to Giphy?", "Yes", "No"); if (shouldUpload) { UploadGIFToGiphy(); } #else NativeUI.AlertPopup popup = NativeUI.ShowTwoButtonAlert("Export Completed", "A GIF file has been created. Do you want to upload it to Giphy?", "Yes", "No"); if (popup != null) { popup.OnComplete += (int buttonId) => { if (buttonId == 0) { UploadGIFToGiphy(); } }; } #endif }
// This callback is called once the uploading has completed. // It receives the URL of the uploaded image. void OnGiphyUploadCompleted(string url) { progressText.text = "DONE"; isUploadingGif = false; uploadedGifUrl = url; #if UNITY_EDITOR bool shouldOpen = UnityEditor.EditorUtility.DisplayDialog("Upload Completed", "The GIF image has been uploaded to Giphy at " + url + ". Open it in the browser?", "Yes", "No"); if (shouldOpen) { Application.OpenURL(uploadedGifUrl); } #else NativeUI.AlertPopup alert = NativeUI.ShowTwoButtonAlert("Upload Completed", "The GIF image has been uploaded to Giphy at " + url + ". Open it in the browser?", "Yes", "No"); if (alert != null) { alert.OnComplete += (int buttonId) => { if (buttonId == 0) { Application.OpenURL(uploadedGifUrl); } }; } #endif }
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 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 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 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 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); } }); } }
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."); } }; } } }
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; } } }
void Update() { // Exit on Android Back button if (Input.GetKeyUp(KeyCode.Escape)) { NativeUI.AlertPopup alert = NativeUI.ShowTwoButtonAlert( title, message, yesButton, noButton ); if (alert != null) { alert.OnComplete += (int button) => { switch (button) { case 0: // Yes Application.Quit(); break; case 1: // No break; } }; } } }
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(); }
void Update() { #if UNITY_ANDROID if (Input.GetKeyUp(KeyCode.Escape)) { // Ask if user wants to exit NativeUI.AlertPopup alert = NativeUI.ShowTwoButtonAlert("Exit App", "Do you want to exit?", "Yes", "No"); if (alert != null) { alert.OnComplete += delegate(int button) { if (button == 0) { Application.Quit(); } } } ; } #endif }
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 }
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."); } }
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 ShowRequestTrackingAuthorizationPopup() { Privacy.AppTrackingManager.RequestTrackingAuthorization(status => { NativeUI.Alert("Request Tracking Completed", "Tracking authorization request completed with result: " + status.ToString()); }); }
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 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 + "\"."); } } }
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 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(); }
protected override void CreateWithMatchmaker() { GameServices.TurnBased.CreateWithMatchmakerUI( MatchRequest, () => { }, error => NativeUI.Alert("Error", "Failed to create a match with MatchMakerUI. Error: " + error)); }
private IEnumerator CRDeleteContact(ContactView view, Contact contact) { yield return(StartCoroutine(CRRequestPermission(AndroidPermission.AndroidPermissionWriteContacts))); if (contact == null) { yield break; } var message = string.Format("Delete contact with id: " + (contact.Id ?? "null")); var alert = NativeUI.ShowTwoButtonAlert("Delete Contact", message, "Yes", "No"); alert.OnComplete += button => { if (button == 1) // Click No { return; } var deleteResult = DeviceContacts.DeleteContact(contact); if (deleteResult != null) { Debug.LogWarning(deleteResult); return; } createdViews.Remove(view); Destroy(view.gameObject); }; }
IEnumerator CRSaveScreenshot() { yield return(new WaitForEndOfFrame()); TwoStepScreenshotPath = Sharing.SaveScreenshot(TwoStepScreenshotName); NativeUI.Alert("Alert", "A new screenshot was saved at " + TwoStepScreenshotPath); }
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 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 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 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 ShowOneButtonAlert() { NativeUI.AlertPopup alert = NativeUI.Alert("Sample Alert", "This is a simple (1-button) alert."); if (alert != null) { alert.OnComplete += OnAlertComplete; } }