void SnapShot()
    {
        //ScreenCapture capture = GetComponent<ScreenCapture>();

        //        string filePath;
        //        string subPath;
        //#if UNITY_ANDROID && !UNITY_EDITOR
        //        subPath = Constants.PhoneSDCardPath;
        //        filePath = subPath + capture.GetFileName(resolution.width, resolution.height);
        //#elif UNITY_EDITOR
        //        subPath = Application.dataPath + "/Screenshots/";
        //        if (!Directory.Exists(subPath))
        //            Directory.CreateDirectory(subPath);
        //        filePath = subPath + capture.GetFileName(resolution.width, resolution.height);
        //#endif
        //        Debug.Log("File path: " + filePath);
        //        capture.SaveScreenshot(CaptureMethod.ReadPixels_Asynch, filePath);

        //        Directory.GetFiles(filePath);

        //float x = (Screen.width * 0.5f) - (resolution.width * 0.5f);
        //float y = Screen.height - resolution.height;
        //Rect rect = new Rect(x, y, resolution.width, resolution.height);
        //NativeToolkit.SaveScreenshot(ScreenCapture.GetFileName(resolution.width, resolution.height), Application.productName, screenArea: rect);

        Texture2D tex = new Texture2D(_camTex.width, _camTex.height);

        tex.SetPixels(_camTex.GetPixels());
        tex.Apply();

        string fileName = ScreenCapture.GetFileName(resolution.width, resolution.height);

        NativeToolkit.SaveImage(tex, fileName);
    }
    private void TakePictureCallback(string path)
    {
        if (path != null)
        {
            // Create a Texture2D from the captured image in the cache
            Texture2D texture = NativeCamera.LoadImageAtPath(path, 1024);

            if (texture == null)
            {
                Debug.Log("Couldn't load texture from " + path);
                return;
            }

            // create sprite from the texture
            Sprite newSprite = Sprite.Create(texture, new Rect(Vector2.zero, new Vector2(texture.width, texture.height)), new Vector2(.5f, .5f));

            if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
            {
                Permission.RequestUserPermission(Permission.ExternalStorageWrite);
            }

            if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
            {
                NotificationManager.Instance.ShowNotification("External Write Permission Required");
                return;
            }

            PathOfCurrentImage = NativeToolkit.SaveImage(texture, "Recipes");

            print($"CameraManager: Path of Image {PathOfCurrentImage}");

            OnPictureTaken?.Invoke(newSprite);
        }
    }
예제 #3
0
 public void SavePhoto()
 {
     if (RunOnRealPhone)
     {
         NativeToolkit.SaveImage(texture2Save, "KARARA" + savedPhotoCount.ToString());
     }
     else
     {
         Debug.Log("save image KARARA" + savedPhotoCount.ToString());
     }
     savedPhotoCount++;
 }
예제 #4
0
파일: Menu.cs 프로젝트: pchahal/paintcraft
    public void OnShareButton()
    {
        string fileName = PlayerPrefs.GetString("CurrentSkinPath");

        fileName = System.IO.Path.GetFileNameWithoutExtension(fileName);


        if (PlayerPrefs.GetInt("HasPurchasedIAP") == 1)
        {
            NativeToolkit.SaveImage(stevePaintable.GetComponent <Steve>().GetCurrentSkinTexture(), fileName, "png");
        }
        else
        {
            inappPurchase.SetActive(true);
        }
    }
예제 #5
0
 public void OnSaveImagePress()
 {
     NativeToolkit.SaveImage(texture, "MyImage", "png");
 }