//public Texture2D LoadTexture(string FilePath) //{ // Texture2D Tex2D; // byte[] FileData; // if (System.IO.File.Exists(FilePath)) // { // FileData = System.IO.File.ReadAllBytes(FilePath); // Tex2D = new Texture2D(resWidth * 3, resHeight * 3); // Create new "empty" texture // if (Tex2D.LoadImage(FileData)) // Load the imagedata into the texture (size is set automatically) // return Tex2D; // If data = readable -> return texture // } // return null; // Return null if load failed //} private IEnumerator TakeScreenshotAndSave() { takeHiResShot = true; _cm.ChangeCanvasState(CanvasManager.canvasState.offAll); yield return(new WaitForEndOfFrame()); Texture2D ss = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); ss.ReadPixels(new Rect(0, 0, Screen.width * 3, Screen.height * 3), 0, 0); ss.Apply(); _cm.ChangeCanvasState(CanvasManager.canvasState.onAll); animationWolf.DefauldAnimState(); // Save the screenshot to Gallery/Photos string name = string.Format("{0}_Capture{1}_{2}.png", Application.productName, "{0}", System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")); Debug.Log("Permission result: " + NativeGallery.SaveImageToGallery(ss, "AR" + " Captures", name)); string filePath = Path.Combine(Application.temporaryCachePath, "shared img.png"); File.WriteAllBytes(filePath, ss.EncodeToPNG()); nativeShare = new NativeShare().AddFile(filePath); _cm.ChangeCanvasState(CanvasManager.canvasState.afterFoto, LoadNewSprite(ss)); takeHiResShot = false; }
public void ShareScreenshot(byte[] pngData) { var pngDataPath = Application.persistentDataPath + "/screenshot-share.png"; File.WriteAllBytes(pngDataPath, pngData); NativeShare.Share("", pngDataPath, null, "", "image/png", true, "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 NativeShare() { var nativeShare = new NativeShare(); nativeShare.SetText("Check out this match!\n\nCopy the link below and paste it in your browser or directly in the GO:View app to watch it:\n\n" + match.GetSharecodeUrl()); nativeShare.Share(); }
public void SaveImage() { var saved = RenderTexture.active; RenderTexture.active = paintingTexture; Texture2D t2d = new Texture2D(paintingTexture.width, paintingTexture.height, TextureFormat.ARGB32, mipChain: false); t2d.ReadPixels(new Rect(0, 0, paintingTexture.width, paintingTexture.height), 0, 0); RenderTexture.active = saved; byte[] pngBytes = t2d.EncodeToPNG(); Debug.Log("SAVING " + Application.persistentDataPath); Directory.CreateDirectory(Application.persistentDataPath + "/gallery"); string randomName = Guid.NewGuid().ToString(); if (image1.activeSelf == true) { randomName = "1-" + randomName; } else { randomName = "2-" + randomName; } string savePath = Application.persistentDataPath + $"/gallery/{randomName}.png"; File.WriteAllBytes(savePath, pngBytes); NativeShare.Share("hi", savePath, "", "subject", "image/png", true, ""); }
private void Start() { // Getting Shot Camera locally screenShotCamGO = GameObject.FindGameObjectWithTag("ScreenShotCamera"); screenShotcam = screenShotCamGO.GetComponent <Camera>(); screenShotcam.enabled = false; // Getting AR Camera locally arCameGO = GameObject.FindGameObjectWithTag("MainCamera"); arCam = arCameGO.GetComponent <Camera>(); arCam.enabled = true; // Getting UI Canvas uiCanvas = GameObject.FindGameObjectWithTag("UI").GetComponent <Canvas>(); // Getting CaptureScreenShot locally captureScreenShot = GameObject.FindObjectOfType <CaptureScreenShot>(); // Storing NativeShare locally nativeShare = GameObject.FindObjectOfType <NativeShare>(); // Storing GeneralButtons locally generalButtons = GameObject.FindGameObjectWithTag("GeneralButtons"); // Storing ScreenShotButtons locally screenShotButtons = GameObject.FindGameObjectWithTag("ScreenShotButtons"); screenShotButtons.SetActive(false); // Storing Status Bar locally statusBarBkground = GameObject.FindGameObjectWithTag("StatusBarBkground"); statusText = GameObject.FindGameObjectWithTag("StatusText").GetComponent <Text>(); }
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(); }
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(); }
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 ShareGame() { PlayButtonSound(); //Play click button sound. //This method will take a screenshot of game and it will add text with the url of the store where this game is published. StartCoroutine(NativeShare.ShareScreenshotWithText("OMG! I have reached " + score.ToString() + " points in Frog Tap! Can you beat my score?")); }
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 ShareText(string text) { #if UNITY_ANDROID AndroidNativeFunctions.ShareText(text, "", "Robo Flight"); #elif UNITY_IOS NativeShare.Share(text); #endif }
public void ShareText(string text) { #if UseNativeShare NativeShare share = new NativeShare(); share.SetText(text); share.Share(); #endif }
public void SharePicture(string path) { #if UseNativeShare NativeShare share = new NativeShare(); share.AddFile(path); share.Share(); #endif }
private IEnumerator delayedShare(string screenShotPath, string text) { while (!File.Exists(screenShotPath)) { yield return(new WaitForSeconds(0.05f)); } NativeShare.Share(text, screenShotPath, "", "", "image/png", chooser: true, ""); }
public void OnShare() { var share = new NativeShare(); share.SetSubject(FrameworkValues.ShareSubject); share.SetText(FrameworkValues.ShareText + "\n https://play.google.com/store/apps/details?id=com.FazApp.TestApp"); share.Share(); }
public void OnClickShare() { PlayTouchSound(); var v_nativeShare = new NativeShare(); v_nativeShare.SetTitle("Download Gravity-Slither game"); v_nativeShare.SetText("Hey there! Download Gravity-Slither game from Google Play Store with the following link https://LINK"); // TODO: Update Google Play Store link v_nativeShare.Share(); }
public void SocialShareFacebook() { List <string> files = new List <string> (); files.Add(Path.Combine(Application.streamingAssetsPath, "logo.png")); files.Add("http://d2ujflorbtfzji.cloudfront.net/key-image/bf8bdf81-e668-4786-ae63-245e6828e7c3.jpg"); NativeShare.ShareFiles(files.ToArray(), ShareApp.Facebook); }
private void NativeShare_Image(string screenShotPath) { string text = ""; string url = ""; string chooserText = "Select sharing app"; text = "Test subject."; NativeShare.Share("Test text", screenShotPath, url, text, "image/png", chooser: true, chooserText); }
public void Share() { NativeShare ns = new NativeShare(); ns.SetTitle("Check Out This AWESOME Game"); ns.SetText("I Just GOT " + GameController.numCorrect + "/10 on the Fast Facts: FBLA QUIZ!! \n" + "https://github.com/kinzorPark/FBLA-Mobile-App-Development"); ns.Share(); }
//CaptureScreenshot runs asynchronously, so you'll need to either capture the screenshot early and wait a fixed time //for it to save, or set a unique image name and check if the file has been created yet before sharing. IEnumerator delayedShare(string screenShotPath, string text) { while (!File.Exists(screenShotPath)) { yield return(new WaitForSeconds(.05f)); } NativeShare.Share(text, true, "Robo Flight", "", screenShotPath, "", "image/*"); }
public void OnShare() { FirebaseManager.LogEvent("share_button_click"); var share = new NativeShare(); share.SetSubject(FrameworkValues.ShareSubject); share.SetText(FrameworkValues.ShareText + "\n" + "https://play.google.com/store/apps/details?id=" + Application.identifier); share.Share(); }
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 }
IEnumerator delayedShare(string screenShotPath, string text) { while (!File.Exists(screenShotPath)) { yield return(new WaitForSeconds(.05f)); } NativeShare.Share(text, screenShotPath, "", "", "image/png", true, ""); print(Application.persistentDataPath);//вывод изображения }
private IEnumerator Share() { yield return(new WaitForEndOfFrame()); var ns = new NativeShare().SetSubject(GameConstants.Social.Share.Subject) .SetTitle(GameConstants.Social.Share.Content).SetText(string.Format(GameConstants.Social.Share.BodyFormat, _scoreDataManager.CurrentScore)) .AddFile(ScreenCapture.CaptureScreenshotAsTexture(), "HighScore.png"); ns.Share(); }
IEnumerator Share() { yield return(new WaitForEndOfFrame()); NativeShare nativeShare = new NativeShare(); nativeShare.SetTitle("Share Highscore."); nativeShare.SetText(string.Format(ShareText, scoreKeeper.HighScore)); nativeShare.Share(); }
//CaptureScreenshot runs asynchronously, so you'll need to either capture the screenshot early and wait a fixed time //for it to save, or set a unique image name and check if the file has been created yet before sharing. IEnumerator delayedShare(string screenShotPath, string text) { while (!File.Exists(screenShotPath)) { yield return(new WaitForSeconds(.1f)); } NativeShare.Share(text, screenShotPath, "", "", "image/png", true, ""); print("Screenshot shared"); }
IEnumerator delayedShare(string screenShotPath, string text) { Debug.Log("Sshare delayed"); while (!File.Exists(screenShotPath)) { Debug.Log("Sshare waiting yeild"); yield return(new WaitForSeconds(.05f)); } NativeShare.Share(text, screenShotPath, "", "", "image/png", true, ""); Invoke("delayedUIVisibility", 2f); }
//CaptureScreenshot runs asynchronously, so you'll need to either capture the screenshot early and wait a fixed time //for it to save, or set a unique image name and check if the file has been created yet before sharing. IEnumerator DelayedShare(string screenShotPath, string text) { while (!File.Exists(screenShotPath)) { // WaitForSeconds freezes if the game is paused (Time.timeScale = 0). // This method is not affected by this. yield return(new WaitForSecondsRealtime(.05f)); } NativeShare.Share(text, screenShotPath, "", "", "image/png", true, ""); }