Ejemplo n.º 1
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, 5, 150, 50), "Get Screenshot"))
        {
            snapShot.GetFullScreenShot(ImageType.JPG);
            //snapShot.GetFullScreenShot(ImageType.JPG, watermark, WatermarkAlignment.TOP_RIGHT);// save with watermark
        }

        if (tex != null && GUI.Button(new Rect(160, 5, 150, 50), "Save"))
        {
            // save screenshot
            snapShot.SaveTextureToGallery(tex, ImageType.JPG);
        }

        // preview
        if (tex != null)
        {
            GUI.Label(new Rect(0, 60, Screen.width, Screen.height), tex);
        }


        if (GUI.Button(new Rect(Screen.width - 120, 10, 100, 40), "Next"))
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene(0);
        }
    }
    void OnGUI()
    {
        GUILayout.Label(log);
        if (GUI.Button(new Rect(20, 20, 150, 50), "Save Full Screen"))
        {
            snapShot.CaptureAndSaveToAlbum();
        }

        GUI.Label(new Rect(20, 70, 500, 20), "------------------------------------------------------------------------------------------------------------------------------");

        GUI.Label(new Rect(20, 100, 50, 20), "X : ");
        x = GUI.TextField(new Rect(80, 100, 50, 20), x);

        GUI.Label(new Rect(160, 100, 50, 20), "Y : ");
        y = GUI.TextField(new Rect(200, 100, 50, 20), y);

        GUI.Label(new Rect(20, 130, 50, 20), "Width : ");
        width = GUI.TextField(new Rect(80, 130, 50, 20), width);

        GUI.Label(new Rect(150, 130, 50, 20), "Height : ");
        height = GUI.TextField(new Rect(200, 130, 50, 20), height);

        if (GUI.Button(new Rect(20, 160, 150, 50), "Save Selected Screen") && int.Parse(width) > 0 && int.Parse(height) > 0)
        {
            snapShot.CaptureAndSaveToAlbum(int.Parse(x), int.Parse(y), int.Parse(width), int.Parse(height));
        }


        GUI.Label(new Rect(20, 230, 500, 20), "------------------------------------------------------------------------------------------------------------------------------");
        GUI.Label(new Rect(70, 250, 200, 50), "Click This Texture to Save");
        if (GUI.Button(new Rect(50, 270, 200, 200), tex) && tex != null)
        {
            snapShot.SaveTextureToGallery(tex);
        }
    }
Ejemplo n.º 3
0
    void _SaveSelfie()
    {
        Texture2D selfieTexture = _GetSelfieTexture();

        _captureAndSave.SaveTextureToGallery(selfieTexture);
        Destroy(selfieTexture);
    }
Ejemplo n.º 4
0
    public void SaveScreenshot()
    {
        // save screenshot
        snapShot.SaveTextureToGallery(tex, ImageType.JPG);
        Sprite sp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height),
                                  new Vector2(0.5f, 0.5f));

        canvas.GetComponent <Image>().sprite = sp;
    }
Ejemplo n.º 5
0
    void OnGUI()
    {
        GUILayout.Label(log);
        if (GUI.Button(new Rect(20, 20, 150, 50), "Save Full Screen"))
        {
            snapShot.CaptureAndSaveToAlbum(ImageType.JPG);
            //snapShot.CaptureAndSaveAtPath(System.IO.Path.Combine(Application.persistentDataPath,"Image.jpg"),ImageType.JPG);
        }

        if (GUI.Button(new Rect(200, 20, 170, 50), "Save in double resolution"))
        {
            snapShot.CaptureAndSaveToAlbum(Screen.width * 2, Screen.height * 2, Camera.main, ImageType.JPG);
        }

        if (GUI.Button(new Rect(380, 20, 170, 50), "Save with watermark"))
        {
            snapShot.CaptureAndSaveToAlbum(Screen.width, Screen.height, Camera.main, ImageType.JPG, watermark, WatermarkAlignment.TOP_LEFT);
        }

        GUI.Label(new Rect(20, 70, 500, 20), "------------------------------------------------------------------------------------------------------------------------------");

        GUI.Label(new Rect(20, 100, 50, 20), "X : ");
        x = GUI.TextField(new Rect(80, 100, 50, 20), x);

        GUI.Label(new Rect(160, 100, 50, 20), "Y : ");
        y = GUI.TextField(new Rect(200, 100, 50, 20), y);

        GUI.Label(new Rect(20, 130, 50, 20), "Width : ");
        width = GUI.TextField(new Rect(80, 130, 50, 20), width);

        GUI.Label(new Rect(150, 130, 50, 20), "Height : ");
        height = GUI.TextField(new Rect(200, 130, 50, 20), height);

        if (GUI.Button(new Rect(20, 160, 150, 50), "Save Selected Screen") && int.Parse(width) > 0 && int.Parse(height) > 0)
        {
            snapShot.CaptureAndSaveToAlbum(int.Parse(x), int.Parse(y), int.Parse(width), int.Parse(height), ImageType.JPG);
        }
        if (GUI.Button(new Rect(200, 160, 250, 50), "Save Selected Screen with watermark") && int.Parse(width) > 0 && int.Parse(height) > 0)
        {
            snapShot.CaptureAndSaveToAlbum(int.Parse(x), int.Parse(y), int.Parse(width), int.Parse(height), ImageType.JPG, watermark, WatermarkAlignment.CENTER);
        }


        GUI.Label(new Rect(20, 230, 500, 20), "------------------------------------------------------------------------------------------------------------------------------");
        GUI.Label(new Rect(70, 250, 200, 50), "Click This Texture to Save");
        if (GUI.Button(new Rect(50, 270, 200, 200), tex) && tex != null)
        {
            snapShot.SaveTextureToGallery(tex, ImageType.JPG);
        }


        if (GUI.Button(new Rect(Screen.width - 120, 10, 100, 40), "Next"))
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene(2);
        }
    }
Ejemplo n.º 6
0
 void OnScreenShot(Texture2D tex2D)
 {
     // assign screenshot
     tex             = tex2D;
     savedIMG.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
     snapShot.SaveTextureToGallery(tex2D);
     isWaitShot   = true;
     waitShotTime = 1f;
     imgDone.SetActive(true);
     //StartCoroutine (waitShowShot ());
 }
Ejemplo n.º 7
0
    IEnumerator SaveToAlbum()
    {
        if (!IsFileExist(STATISTIC_SCREENSHOT))
        {
            //      log01 = "file is writed to device!";
#if !UNITY_WEBPLAYER
            File.WriteAllBytes(GetDefaultFilePath() + STATISTIC_SCREENSHOT, mTexture.EncodeToPNG());
#endif
        }

        while (!IsFileExist(STATISTIC_SCREENSHOT))
        {
            yield return(new WaitForSeconds(0.05f));
        }

        //   log02 = "file is existed!";
        #if UNITY_EDITOR
                #elif UNITY_IPHONE
        snapShot.SaveTextureToGallery(mTexture);
#elif UNITY_ANDROID
        snapShot.SaveTextureToGallery(mTexture);
#endif
    }
Ejemplo n.º 8
0
    void OnGUI()
    {
        guiStyle.fontSize = 20;
        GUILayout.Label(log, guiStyle);
        if (GUI.Button(new Rect(20, 200, 150, 50), "Save Full Screen"))
        {
            // Saves image locally to C:\Users\gwany\Pictures\
            snapShot.CaptureAndSaveToAlbum(ImageType.JPG);
            // Saves image on device
            // snapShot.CaptureAndSaveAtPath(System.IO.Path.Combine(Application.persistentDataPath,"Image.jpg"),ImageType.JPG);
            // Save image to Assets folder
            // snapShot.CaptureAndSaveAtPath(Application.dataPath + "/Resources/AppImages/", ImageType.JPG);
        }

        if (GUI.Button(new Rect(200, 290, 170, 50), "Save in double resolution"))
        {
            snapShot.CaptureAndSaveToAlbum(Screen.width * 2, Screen.height * 2, Camera.main, ImageType.JPG);
        }

        GUI.Label(new Rect(20, 190, 500, 20), "------------------------------------------------------------------------------------------------------------------------------");

        GUI.Label(new Rect(20, 280, 50, 20), "X : ");
        x = GUI.TextField(new Rect(80, 280, 50, 20), x);

        GUI.Label(new Rect(160, 280, 50, 20), "Y : ");
        y = GUI.TextField(new Rect(200, 280, 50, 20), y);

        GUI.Label(new Rect(20, 310, 50, 20), "Width : ");
        width = GUI.TextField(new Rect(80, 310, 50, 20), width);

        GUI.Label(new Rect(150, 310, 50, 20), "Height : ");
        height = GUI.TextField(new Rect(200, 310, 50, 20), height);

        if (GUI.Button(new Rect(20, 340, 150, 50), "Save Selected Screen") && int.Parse(width) > 0 && int.Parse(height) > 0)
        {
            snapShot.CaptureAndSaveToAlbum(int.Parse(x), int.Parse(y), int.Parse(width), int.Parse(height), ImageType.JPG);
        }


        GUI.Label(new Rect(20, 410, 500, 20), "------------------------------------------------------------------------------------------------------------------------------");
        GUI.Label(new Rect(70, 430, 200, 50), "Click This Texture to Save");
        if (GUI.Button(new Rect(50, 450, 200, 200), tex) && tex != null)
        {
            snapShot.SaveTextureToGallery(tex, ImageType.JPG);
        }
    }
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, 5, 150, 50), "Get Screenshot"))
        {
            snapShot.GetFullScreenShot();
        }

        if (tex != null && GUI.Button(new Rect(160, 5, 150, 50), "Save"))
        {
            // save screenshot
            snapShot.SaveTextureToGallery(tex);
        }

        // preview
        if (tex != null)
        {
            GUI.Label(new Rect(0, 60, Screen.width, Screen.height), tex);
        }
    }
    void OnGUI()
    {
        GUILayout.Label(log);
        if (GUI.Button(new Rect(20, 20, 150, 50), "Save Full Screen"))
        {
            snapShot.CaptureAndSaveToAlbum();
            //snapShot.CaptureAndSaveAtPath(System.IO.Path.Combine(Application.persistentDataPath,"Image.jpg"));
        }

        if (GUI.Button(new Rect(200, 20, 170, 50), "Save in double resolution"))
        {
            snapShot.CaptureAndSaveToAlbum(Screen.width * 2, Screen.height * 2, Camera.main);
        }

        GUI.Label(new Rect(20, 70, 500, 20), "------------------------------------------------------------------------------------------------------------------------------");

        GUI.Label(new Rect(20, 100, 50, 20), "X : ");
        x = GUI.TextField(new Rect(80, 100, 50, 20), x);

        GUI.Label(new Rect(160, 100, 50, 20), "Y : ");
        y = GUI.TextField(new Rect(200, 100, 50, 20), y);

        GUI.Label(new Rect(20, 130, 50, 20), "Width : ");
        width = GUI.TextField(new Rect(80, 130, 50, 20), width);

        GUI.Label(new Rect(150, 130, 50, 20), "Height : ");
        height = GUI.TextField(new Rect(200, 130, 50, 20), height);

        if (GUI.Button(new Rect(20, 160, 150, 50), "Save Selected Screen") && int.Parse(width) > 0 && int.Parse(height) > 0)
        {
            snapShot.CaptureAndSaveToAlbum(int.Parse(x), int.Parse(y), int.Parse(width), int.Parse(height));
        }


        GUI.Label(new Rect(20, 230, 500, 20), "------------------------------------------------------------------------------------------------------------------------------");
        GUI.Label(new Rect(70, 250, 200, 50), "Click This Texture to Save");
        if (GUI.Button(new Rect(50, 270, 200, 200), tex) && tex != null)
        {
            snapShot.SaveTextureToGallery(tex);
        }
    }
Ejemplo n.º 11
0
    public string SavePhoto(Texture2D photo, bool saveOnNativeGallery = true)
    {
        if (saveOnNativeGallery && captureAndSavePlugin != null)
        {
            captureAndSavePlugin.SaveTextureToGallery(photo);
            Debug.Log("Saved photo on Gallery");
        }

        //NatCam.SavePhoto(photo, SaveMode.SaveToPhotoAlbum, Orientation.Rotation_0, new SaveCallback(onSave));
        if (!Directory.Exists(Application.persistentDataPath + savingFolder))
        {
            Directory.CreateDirectory(Application.persistentDataPath + savingFolder);
        }
        string path = Application.persistentDataPath + savingFolder + "screenshot_" +
                      DateTime.Now.Millisecond + ".png";

        System.IO.File.WriteAllBytes(path, photo.EncodeToPNG());
        Debug.Log("Saved photo on path: " + path);

        return(path);
        //onSave(path);
    }
Ejemplo n.º 12
0
 public void SaveTextureToGallery(Texture2D tex, ImageType Itype)
 {
     snapShot.SaveTextureToGallery(tex, Itype);
 }