Beispiel #1
0
 public void ScreenShot()
 {
     if (Input.GetKeyUp(KeyCode.Mouse0))
     {
         captureScreenshot("true");
         ssButton.SetActive(false);
         backButton.SetActive(false);
         colorButton.SetActive(false);
         testColor.SetActive(false);
         Slider_T.SetActive(false);
         Text_t.SetActive(false);
         Slider_S.SetActive(false);
         Text_S.SetActive(false);
     }
 }
Beispiel #2
0
    void Start()
    {
        screenCap = new Texture2D(300, 200, TextureFormat.RGB24, false);   // 1
        border    = new Texture2D(2, 2, TextureFormat.ARGB32, false);      // 2
        border.Apply();

        ssButton.SetActive(true);
        backButton.SetActive(true);
        colorButton.SetActive(true);
        testColor.SetActive(true);
        Slider_T.SetActive(true);
        Text_t.SetActive(true);
        Slider_S.SetActive(true);
        Text_S.SetActive(true);
    }
Beispiel #3
0
    public IEnumerator Capture()
    {
        yield return(new WaitForEndOfFrame());

        screenCap.ReadPixels(new Rect(198, 98, 298, 198), 0, 0);
        screenCap.Apply();

        // Encode texture into PNG
        byte[] bytes = screenCap.EncodeToPNG();
        //Object.Destroy(screenCap);

        // For testing purposes, also write to a file in the project folder

        string screenshotFilename = "Green_" + System.DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".JPG";

        Application.CaptureScreenshot(screenshotFilename);


        if (Application.platform == RuntimePlatform.Android)
        {
            string myFolderLocation = "/sdcard/DCIM/Asd/";


            if (!System.IO.Directory.Exists(myFolderLocation))
            {
                System.IO.Directory.CreateDirectory(myFolderLocation);
            }

            movePath = myFolderLocation + screenshotFilename;
        }


        filePath = screenshotFilename;

        shot = true;

        ssButton.SetActive(true);
        backButton.SetActive(true);
        testColor.SetActive(true);
        colorButton.SetActive(true);
        Slider_T.SetActive(true);
        Text_t.SetActive(true);
        Slider_S.SetActive(true);
        Text_S.SetActive(true);


        ActiveUrl = movePath;

        // string action = Intent.ACTION_MEDIA_SCANNER_SCAN_FILE
        AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
        string           action      = intentClass.GetStatic <string>("ACTION_MEDIA_SCANNER_SCAN_FILE");

        // Intent intentObject = new Intent(action);
        AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent", action);

        // Uri uriObject = Uri.parse("file:" + filePath);
        AndroidJavaClass  uriClass  = new AndroidJavaClass("android.net.Uri");
        AndroidJavaObject uriObject = uriClass.CallStatic <AndroidJavaObject>("parse", "file://" + movePath);

        // intentObject.setData(uriObject);
        intentObject.Call <AndroidJavaObject>("setData", uriObject);

        // this.sendBroadcast(intentObject);
        AndroidJavaClass  unity           = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = unity.GetStatic <AndroidJavaObject>("currentActivity");

        currentActivity.Call("sendBroadcast", intentObject);
    }