public void shareScore() { FindObjectOfType <GameCode>().playSound(GameCode.Sound.Button); string screenshotName = "mimo_highscore.png"; // wait for graphics to render new WaitForEndOfFrame(); string screenShotPath = Application.persistentDataPath + "/" + screenshotName; ScreenCapture.CaptureScreenshot(screenshotName, 1); new WaitForSeconds(0.5f); string appPackageName = Application.identifier; var shareSubject = "Fam! I challenge you to beat my high score in" + " Mimo"; var shareMessage = "Fam! I challenge you to beat my high score in" + " Mimo" + "\nDownload Mimo from the link below." + "\n\n" + "https://play.google.com/store/apps/details?id=" + appPackageName; NativeShare shareIntent = new NativeShare(); shareIntent.AddFile(screenShotPath, null); shareIntent.SetSubject(shareSubject); shareIntent.SetText(shareMessage); shareIntent.SetTitle("Share your score with friends..."); shareIntent.Share(); }
private IEnumerator GetImageFileAndShare() { yield return(new WaitForEndOfFrame()); //Texture2D ss = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); //ss.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); //ss.Apply(); var nativeShareInstance = new NativeShare(); var imageTextureList = ImageController.Instance.GetImageTextureList(); foreach (var texture in imageTextureList) { string filePath = Path.Combine(Application.temporaryCachePath, "shared img.png"); File.WriteAllBytes(filePath, texture.EncodeToPNG()); nativeShareInstance.AddFile(filePath); } nativeShareInstance.SetSubject("Subject goes here").SetText("Hello world!") .SetCallback((result, shareTarget) => Debug.Log("Share result: " + result + ", selected app: " + shareTarget)) .Share(); ImageController.Instance.ClearImageTextureList(); // Share on WhatsApp only, if installed (Android only) //if( NativeShare.TargetExists( "com.whatsapp" ) ) // new NativeShare().AddFile( filePath ).AddTarget( "com.whatsapp" ).Share(); }
IEnumerator C_TakePhoto() { isProcessing = true; yield return(new WaitForEndOfFrame()); string file = "Screen_" + GetTimestamp(DateTime.Now) + ".png"; ScreenCapture.CaptureScreenshot(file); file = Application.persistentDataPath + "/" + file; int count = 0; while (!System.IO.File.Exists(file) || count > 4) { yield return(null); } if (count > 4) { Debug.Log("Error too much time taking photo"); } else { NativeShare nativeShare = new NativeShare(); nativeShare.AddFile(file); nativeShare.Share(); } isProcessing = false; }
public void Share() { NativeGallery.SaveImageToGallery(PhotoFilePath, "TestAR", "Screenshot.png"); myNativeShare = new NativeShare(); myNativeShare.AddFile(PhotoFilePath); myNativeShare.Share(); }
public void OnShare() { //get stuff from the canvas. for (int f = 0; f < canvas.transform.childCount; f++) { Transform currentItem = canvas.transform.GetChild(f); //search by name if (currentItem.name.Equals("Title")) { title = currentItem.GetComponentInChildren <Text>().text; } //search by name if (currentItem.name.Equals("Description Scroller")) { description = currentItem.GetComponentInChildren <Text>().text; } } //set subject subject = "Historical Information on " + title; //create nativeshare object NativeShare native = new NativeShare(); //set variables for nativeshare object native.SetSubject(subject); native.SetText(description); native.SetTitle(title); native.AddFile("Assets/Images/startscreen2.jpg", ".jpg"); //try some freaky shit native.Share(); }
public void Share() { //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PHOTO // create the texture Texture2D screenTexture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, true); // put buffer into texture screenTexture.ReadPixels(new Rect(0f, 0f, Screen.width, Screen.height), 0, 0); // apply screenTexture.Apply(); //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PHOTO byte[] dataToSave = screenTexture.EncodeToPNG(); string destination = Path.Combine(Application.persistentDataPath, System.DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".png"); File.WriteAllBytes(destination, dataToSave); if (!Application.isEditor) { string textLang = Lean.Localization.LeanLocalization.CurrentLanguage == "Russian" ? "ShareTextRussian" : "ShareTextEnglish"; string shareText = RemoteSettings.GetString(textLang, string.Empty); NativeShare share = new NativeShare(); share.AddFile(destination).SetText(shareText).Share(); } }
public void SharePicture(string path) { #if UseNativeShare NativeShare share = new NativeShare(); share.AddFile(path); share.Share(); #endif }
public void PrintPdf() { _currentDeck.Name = nameInputField.text; var deck = _currentDeck; Uri pdfUri = null; try { pdfUri = deck.PrintPdf(); } catch (Exception e) { Debug.LogError(DeckPrintErrorMessage + e.Message + e.StackTrace); CardGameManager.Instance.Messenger.Show(DeckPrintErrorMessage + e.Message); } if (pdfUri == null || !pdfUri.IsAbsoluteUri) { Debug.LogError(DeckPrintOpenErrorMessage); CardGameManager.Instance.Messenger.Show(DeckPrintOpenErrorMessage); return; } #if ENABLE_WINMD_SUPPORT UnityEngine.WSA.Application.InvokeOnUIThread(async() => { try { var file = await Windows.Storage.StorageFile.GetFileFromPathAsync(pdfUri.LocalPath); if (file != null) { // Launch the retrieved file var success = await Windows.System.Launcher.LaunchFileAsync(file); if (!success) { Debug.LogError(DeckPrintOpenPathErrorMessage + pdfUri.LocalPath); CardGameManager.Instance.Messenger.Show(DeckPrintOpenPathErrorMessage + pdfUri.LocalPath); } } else { Debug.LogError(DeckPrintOpenPathErrorMessage + pdfUri.LocalPath); CardGameManager.Instance.Messenger.Show(DeckPrintOpenPathErrorMessage + pdfUri.LocalPath); } } catch (Exception e) { Debug.LogError(e.Message + e.StackTrace); CardGameManager.Instance.Messenger.Show(DeckPrintOpenPathErrorMessage + pdfUri.LocalPath); } }, false); #elif (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR var nativeShare = new NativeShare(); nativeShare.AddFile(pdfUri.AbsoluteUri, "application/pdf").Share(); #else Application.OpenURL(pdfUri.AbsoluteUri); #endif }
private IEnumerator TakeSanpShotAndShare() { yield return(new WaitForEndOfFrame()); Texture2D ss = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); ss.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); ss.Apply(); string filePath = Path.Combine(Application.temporaryCachePath, "shared img.png"); File.WriteAllBytes(filePath, ss.EncodeToPNG()); Destroy(ss); ns.AddFile(filePath).SetSubject("Shared File").SetText("Hello From Unity"); ns.Share(); }
IEnumerator RecordFrameAndShare() { yield return(new WaitForEndOfFrame()); var texture = ScreenCapture.CaptureScreenshotAsTexture(); NativeShare shareScreen = new NativeShare(); shareScreen.SetSubject("Prez Hopper"); shareScreen.AddFile(texture, "score.png"); shareScreen.SetText("Check out my score on Prez Hopper!"); shareScreen.Share(); // cleanup Object.Destroy(texture); }
public static void ShareFiles(IEnumerable <string> filePaths, string text = "", string subject = "") { var nativeShare = new NativeShare().SetSubject(subject).SetText(text); if (filePaths != null) { foreach (var path in filePaths) { nativeShare.AddFile(path); } } nativeShare.Share(); }
public static void ShareJsonFiles(List <string> pathList, string subject, string text) { var nativeShare = new NativeShare(); foreach (string path in pathList) { if (ValidatePath(path)) { nativeShare.AddFile(path); } } nativeShare.SetSubject(subject).SetText(text); nativeShare.Share(); }
public static void ShareZip(string path, string subject, string text) { var nativeShare = new NativeShare(); if (ValidatePath(path)) { nativeShare.AddFile(path); } else { Debug.LogWarning("path to zip not valid"); } nativeShare.SetSubject(subject).SetText(text); nativeShare.Share(); }
public void Share() { // write captured data to a text file string path = Application.persistentDataPath + "/" + s_TextFileName; StreamWriter writer = new StreamWriter(path, false); for (int i = 0; i < m_BodyRuntimeRecorder.JointPositions.Count; i++) { writer.WriteLine(m_BodyRuntimeRecorder.JointPositions[i].ToString("F7") + "," + m_BodyRuntimeRecorder.JointRotations[i].ToString("F7")); } writer.Close(); // native share via native share plugin https://assetstore.unity.com/packages/tools/integration/native-share-for-android-ios-112731 NativeShare m_nativeShare = new NativeShare(); m_nativeShare.AddFile(Application.persistentDataPath + "/" + s_TextFileName); m_nativeShare.Share(); }
public void ShareScreenshot() { if (ss == null) { return; } //Debug.Log("Permission result: " + NativeGallery.SaveImageToGallery(ss, Application.productName, name)); string filePath = Path.Combine(Application.temporaryCachePath, ssName + ".png"); File.WriteAllBytes(filePath, ss.EncodeToPNG()); NativeShare nativeShare = new NativeShare(); nativeShare.SetSubject("MuseoAR Selfie!"); // Primarily for email. //nativeShare.SetText(""); nativeShare.AddFile(filePath, "image/png"); nativeShare.SetTitle("Score in Sunset Falls"); nativeShare.Share(); }
public void ShareMedia() { NativeShare nativeShare = new NativeShare(); string filePath; if (mediaInPreview == MediaType.Picture) { filePath = Path.Combine(Application.temporaryCachePath, "shared_picture.jpg"); File.WriteAllBytes(filePath, lastPictureTaken.EncodeToJPG()); } else { filePath = lastVideoPath; } nativeShare.SetTitle(shareMediaTitle); nativeShare.SetText(shareMediaText); nativeShare.AddFile(filePath); nativeShare.Share(); }
public void SharePIN() { var tex = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); // Read screen contents into the texture tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0); tex.Apply(); byte[] bytes = tex.EncodeToJPG(); string path = Application.persistentDataPath + "/ScreenShot.jpg"; File.WriteAllBytes(path, bytes); Destroy(tex); NativeShare share = new NativeShare(); share.SetSubject("Gamify PIN Code"); share.SetTitle("Gamify PIN Code"); share.SetText("Come join our challenge at GamifyBankify!\nThe PIN Code is: " + challenge.PIN); share.AddFile(path); share.Share(); }
public static void ShareImage(Texture2D texture, string screenshotName, string title = "", string subject = "", string description = "", TextureExporter.ImageFileFormat imageFormat = TextureExporter.ImageFileFormat.PNG, int JPGQuality = 70) { #if !UNITY_EDITOR && (UNITY_IOS || UNITY_ANDROID) string format = (imageFormat == TextureExporter.ImageFileFormat.JPG) ? "jpeg" : "png"; string filename = screenshotName + "." + format; // On iOS and Android share using Native Share var nativeShare = new NativeShare(); nativeShare.AddFile(texture, filename); nativeShare.SetTitle(title); nativeShare.SetSubject(subject); nativeShare.SetText(description); nativeShare.Share(); #elif !UNITY_EDITOR && UNITY_WEBGL // On WebGL share using custom share plugin // Convert texture to bytes byte[] bytes = null; if (imageFormat == TextureExporter.ImageFileFormat.JPG) { bytes = texture.EncodeToJPG(JPGQuality); } else { bytes = texture.EncodeToPNG(); } // Try sharing try { string format = (imageFormat == TextureExporter.ImageFileFormat.JPG) ? "jpeg" : "png"; WebGLUtils.ShareImage(bytes, screenshotName, format); } catch { Debug.LogError("Failed to share image."); } #else Debug.LogError("Share not supported on this platform."); #endif }