Exemple #1
0
        IEnumerator CRCaptureScreenshot()
        {
            // Wait for right timing to take screenshot
            yield return(new WaitForEndOfFrame());

            #if UNITY_ANDROID
            if (screenshotRT != null)
            {
                // Temporarily render the camera content to our screenshotRenderTexture.
                // Later we'll share the screenshot from this rendertexture.
                Camera.main.targetTexture = screenshotRT;
                Camera.main.Render();
                yield return(null);

                Camera.main.targetTexture = null;
                yield return(null);

                // Read the rendertexture contents
                RenderTexture.active = screenshotRT;

                capturedScreenshot = new Texture2D(screenshotRT.width, screenshotRT.height, TextureFormat.RGB24, false);
                capturedScreenshot.ReadPixels(new Rect(0, 0, screenshotRT.width, screenshotRT.height), 0, 0);
                capturedScreenshot.Apply();

                RenderTexture.active = null;
            }
            #else
            capturedScreenshot = MobileNativeShare.CaptureScreenshot();
            #endif
        }
        IEnumerator CRCaptureScreenshot()
        {
            // Wait for right timing to take screenshot
            yield return(new WaitForEndOfFrame());

            capturedScreenshot = MobileNativeShare.CaptureScreenshot();
        }
Exemple #3
0
        public void ShareScreenshot()
        {
            string path = System.IO.Path.Combine(Application.persistentDataPath, screenshotFilename);
            string msg  = shareMessage;

            msg = msg.Replace("[score]", ScoreManager.Instance.Score.ToString());
            MobileNativeShare.ShareImage(path, screenshotFilename, msg);
        }
        IEnumerator CRSaveScreenshot()
        {
            yield return(new WaitForEndOfFrame());

            TwoStepScreenshotPath = MobileNativeShare.SaveScreenshot(TwoStepScreenshotName);

            Debug.Log("A new screenshot was saved at " + TwoStepScreenshotPath);
        }
Exemple #5
0
    void ShareURL(string url)
    {
        if (string.IsNullOrEmpty(url))
        {
            Debug.LogWarning("ShareURL failed: the given URL is invalid.");
            return;
        }

        MobileNativeShare.ShareURL(url);
    }
 public void ShareScreenshot()
 {
     if (!string.IsNullOrEmpty(TwoStepScreenshotPath))
     {
         MobileNativeShare.ShareImage(TwoStepScreenshotPath, sampleMessage);
     }
     else
     {
         Debug.Log("Please save a screenshot first.");
     }
 }
Exemple #7
0
    IEnumerator CROneStepSharing()
    {
        yield return(new WaitForEndOfFrame());

        HidePanel();
        yield return(new WaitForSeconds(0.35f));

        bottomBanner.SetActive(true);
        yield return(new WaitForEndOfFrame());

        MobileNativeShare.ShareScreenshot("screenshot", "");
        bottomBanner.SetActive(false);
    }
Exemple #8
0
        public void ShareScreenshot()
        {
            if (capturedScreenshot == null)
            {
                Debug.Log("ShareScreenshot: FAIL. No captured screenshot.");
                return;
            }

            string msg = shareMessage;

            msg = msg.Replace("[score]", ScoreManager.Instance.Score.ToString());
            MobileNativeShare.ShareTexture2D(capturedScreenshot, screenshotFilename, msg);
        }
Exemple #9
0
    IEnumerator ScreenShot()
    {
        yield return(new WaitForEndOfFrame());

        Texture2D pic = MobileNativeShare.CaptureScreenshot();

        if (pic == null)
        {
            Debug.Log("Texture from screenshot not successful.");
        }

        MobileNativeShare.ShareTexture2D(pic, "LerperScreen", "", "");
    }
Exemple #10
0
    void SharePNG()
    {
        if (ImgTex == null)
        {
            Debug.Log("SharePNG failed: no captured screenshot.");
            return;
        }

        #if EASY_MOBILE
        MobileNativeShare.ShareTexture2D(ImgTex, ScreenshotSharer.Instance.pngFilename, ConstructShareMessage());
        #else
        Debug.Log("Sharing feature requires Easy Mobile plugin.");
        #endif
    }
Exemple #11
0
        public void ShareScreenshot()
        {
            if (capturedScreenshot == null)
            {
                Debug.Log("ShareScreenshot: FAIL. No captured screenshot.");
                return;
            }

            string msg = shareMessage;

            msg = msg.Replace("[score]", ScoreManager.Instance.Score.ToString());

            if (shareAppUrl)
            {
                #if UNITY_IOS
                msg += "\n\n" + AppInfo.Instance.APPSTORE_SHARE_LINK;
                #elif UNITY_ANDROID
                msg += "\n\n" + AppInfo.Instance.PLAYSTORE_SHARE_LINK;
                #endif
            }

            MobileNativeShare.ShareImageByTexture2D(capturedScreenshot, "sglib_screenshot.png", msg);
        }
Exemple #12
0
        IEnumerator CRCaptureScreenshot()
        {
            #if UNITY_ANDROID
            if (screenshotRenderTexture != null)
            {
                // Wait for right timing to take screenshot
                yield return(new WaitForEndOfFrame());

                // Temporarily render the camera content to our screenshotRenderTexture.
                // Later we'll share the screenshot from this rendertexture.
                Camera.main.targetTexture = screenshotRenderTexture;
                Camera.main.Render();
                yield return(null);

                Camera.main.targetTexture = null;
            }
            #else
            // Wait for right timing to take screenshot
            yield return(new WaitForEndOfFrame());

            capturedScreenshot = MobileNativeShare.CaptureFullScreenshot();
            #endif
        }
    IEnumerator CROneStepSharing()
    {
        yield return(new WaitForEndOfFrame());

        MobileNativeShare.ShareScreenshot("screenshot", "");
    }
        IEnumerator CROneStepSharing()
        {
            yield return(new WaitForEndOfFrame());

            MobileNativeShare.ShareScreenshot(OneStepScreenshotName, sampleMessage);
        }
    IEnumerator CROneStepSharing()
    {
        yield return(new WaitForEndOfFrame());

        MobileNativeShare.ShareScreenshot("screenshot", "https://play.google.com/store/apps/details?id=com.applecakestudios.archer");
    }
Exemple #16
0
        IEnumerator DisplayMenuUI(float delay = 0f, bool isGameOverUI = false)
        {
            if (delay > 0f)
            {
                yield return(new WaitForSeconds(delay));
            }

            freeGifts.gameObject.SetActive(true);
            playButton.SetActive(true);
            menuButtons.SetActive(true);
            shareButton.SetActive(false);

            if (!isGameOverUI)
            {
                title.SetActive(true);
            }
            else
            {
                selectCharacterButton.SetActive(false);
                score.gameObject.SetActive(true);

                // Show New Best score.
                if (ScoreManager.Instance.HasNewHighScore)
                {
                    newBestScore.SetActive(true);
                }

                // Show Share button.
                #if UNITY_ANDROID
                if (enableSharing && screenshotRenderTexture != null && screenshotRenderTexture.IsCreated())
                {
                    capturedScreenshot = MobileNativeShare.CaptureFullScreenshot(screenshotRenderTexture);

                    yield return(new WaitForSeconds(0.2f));

                    shareImageSprite = Utilities.Instance.Texture2DToSprite(capturedScreenshot);
                    Transform imgTf   = shareImage.transform;
                    Image     imgComp = imgTf.GetComponent <Image>();

                    float scaleFactor = imgTf.GetComponent <RectTransform>().rect.width / shareImageSprite.rect.width;
                    imgComp.sprite = shareImageSprite;
                    imgComp.SetNativeSize();
                    imgTf.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor);

                    yield return(new WaitForSeconds(0.3f));

                    shareButton.SetActive(true);
                }
                #else
                if (enableSharing && capturedScreenshot != null)
                {
                    yield return(new WaitForSeconds(0.2f));

                    shareImageSprite = Utilities.Instance.Texture2DToSprite(capturedScreenshot);
                    Transform imgTf   = shareImage.transform;
                    Image     imgComp = imgTf.GetComponent <Image>();

                    float scaleFactor = imgTf.GetComponent <RectTransform>().rect.width / shareImageSprite.rect.width;
                    imgComp.sprite = shareImageSprite;
                    imgComp.SetNativeSize();
                    imgTf.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor);

                    yield return(new WaitForSeconds(0.3f));

                    shareButton.SetActive(true);
                }
                #endif
            }
        }
Exemple #17
0
    void ShareLink()
    {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        MobileNativeShare.ShareScreenshot("screenshot", "");
#endif
    }