} //END CallSaveToCameraRollEvent

        //-----------------------------//
        public void SavePhotoToCameraRoll()
        //-----------------------------//
        {
#if NATSHARE
            if( blockEventExternalCamera != null )
            {
                //If we're trying to save the photo from the external camera straight to the camera roll 
                //( instead of to the local storage path in the app using the BlockEventRecorder)
                if( cameraAssetToSaveToRoll == SaveExternalCameraTypeToCameraRoll.CapturedPhoto &&
                    blockEventExternalCamera.capturedPhotos != null && blockEventExternalCamera.capturedPhotos.Count > 0 )
                {
                    if( recorderSaveToRollType == RecorderSaveToCameraRollType.SaveFirst )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventExternalCamera.capturedPhotos[ 0 ] ) )
                        {
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                    }
                    else if( recorderSaveToRollType == RecorderSaveToCameraRollType.SaveLatest )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventExternalCamera.capturedPhotos[ blockEventExternalCamera.capturedPhotos.Count - 1 ] ) )
                        {
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                    }
                }
            }
#else
            Debug.LogError("BlockEventNativeSharing.cs SavePhotoToCameraRoll() ERROR: Missing NATSHARE scripting define symbol in project settings");
            return;
#endif

        } //END SavePhotoToCameraRoll
Beispiel #2
0
        /// <summary>
        /// Raises the save to camera roll button click event.
        /// </summary>
        public void OnSaveToCameraRollButtonClick()
        {
            Debug.Log("OnSaveToCameraRollButtonClick ()");

            if (isVideoPlaying || NatCorder.IsRecording || string.IsNullOrEmpty(videoPath))
            {
                return;
            }

            NatShare.SaveToCameraRoll(videoPath);
        }
Beispiel #3
0
    void OnReplay(string path)
    {
        Debug.Log("Saved recording to: " + path);
        // Playback the video
#if UNITY_IOS
        Handheld.PlayFullScreenMovie("file://" + path);
        NatShare.SaveToCameraRoll(path);
#elif UNITY_ANDROID
        //Handheld.PlayFullScreenMovie(path);
        Debug.Log(path);
        NatShare.SaveToCameraRoll(path);
#endif
    }
        public void OnButtonSaveScreenshotClicked()
        {
            Debug.Log("OnButtonSaveScreenshotClicked");
            if (!File.Exists(GetPathScreenshot()))
            {
                Debug.LogError("Screenshot not exist\nPath: " + GetPathScreenshot());
                return;
            }

            Debug.Log("Screenshot\nPath: " + GetPathScreenshot());
            byte[] screenshotFile = File.ReadAllBytes(GetPathScreenshot());
            screenshotTexture2D = new Texture2D(Screen.width, Screen.height);
            screenshotTexture2D.LoadImage(screenshotFile);
            NatShare.SaveToCameraRoll(screenshotTexture2D);
        }
Beispiel #5
0
    IEnumerator CaptureScreenshot()
    {
        yield return(null);

        GameObject.Find("MainCanvas").GetComponent <Canvas>().enabled = false;
        //Wait for end of frame
        yield return(new WaitForEndOfFrame());

        screenImage = new Texture2D(Screen.width, Screen.height);

        //Get Image from screen
        screenImage.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
        screenImage.Apply();

        NatShare.SaveToCameraRoll(screenImage);

        GameObject.Find("MainCanvas").GetComponent <Canvas>().enabled = true;

        Texture2D.Destroy(screenImage);
    }
Beispiel #6
0
 public void OnSaveToCameraRollButtonClick()
 {
     NatShare.SaveToCameraRoll(texture, "NatCamWithOpenCVForUnityExample");
 }
Beispiel #7
0
 public bool SaveToCameraRoll(string videoPath)
 {
     return(NatShare.SaveToCameraRoll(videoPath));
 }
        } //END CallShareBlockEventRecorder

        //-----------------------------//
        private void CallSaveToCameraRollEvent()
        //-----------------------------//
        {

#if NATSHARE
            if( SaveToCameraRollTypeTexture() && textureToSave != null )
            {
                if( NatShare.SaveToCameraRoll( textureToSave as Texture2D ) )
                {
                    if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                }
            }
            else if( SaveToCameraRollTypePath() && assetPathToSave != null && assetPathToSave != "" )
            {
                if( NatShare.SaveToCameraRoll( assetPathToSave ) )
                {
                    if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                }
            }
            else if( SaveToCameraRollTypeBlockEventExternalCamera() && blockEventExternalCamera != null )
            {
                //Tell the BlockEventExternalCamera that we want to send any photos it captures to the device's camera roll
                if( IsSaveCapturedPhotoToRoll() )
                {
                    blockEventExternalCamera.RequestCapturedPhoto( this );
                }

                //Tell the BlockEventExternalCamera that we want to send the video preview to the device's camera roll
                else if( IsSaveCapturedVideoPreviewToRoll() )
                {
                    if( cameraAssetToSaveToRoll == SaveExternalCameraTypeToCameraRoll.VideoPreview &&
                         blockEventExternalCamera.GetVideoPreview() != null )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventExternalCamera.GetVideoPreview() as Texture2D ) )
                        {
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                    }
                }
            }
            else if( SaveToCameraRollTypeBlockEventRecorder() && blockEventRecorderToSaveToRoll != null )
            {
                if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() At start of trying to save to camera roll. AssetType = " + assetTypeToSaveToRoll + ", capturedPhotos.Length = " + blockEventRecorderToSaveToRoll.capturedPhotos.Count + ", capturedVideos.Length = " + blockEventRecorderToSaveToRoll.recordedVideos.Count ); }

                //If we're trying to save an asset from a Recorder to the camera roll
                if( assetTypeToSaveToRoll == AssetType.Texture &&
                    blockEventRecorderToSaveToRoll.capturedPhotos != null && blockEventRecorderToSaveToRoll.capturedPhotos.Count > 0 )
                {
                    if( recorderShareToRollType == RecorderSaveToCameraRollType.SaveFirst )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventRecorderToSaveToRoll.capturedPhotos[ 0 ] ) )
                        {
                            if( showDebug ){ Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Photo " + recorderShareToRollType + " Succesfully saved Photo! " + blockEventRecorderToSaveToRoll.capturedPhotos[ 0 ] ); }
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                        else
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Photo " + recorderShareToRollType + " Failed!" ); }
                        }
                    }
                    else if( recorderShareToRollType == RecorderSaveToCameraRollType.SaveLatest )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventRecorderToSaveToRoll.capturedPhotos[ blockEventRecorderToSaveToRoll.capturedPhotos.Count - 1 ] ) )
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Photo " + recorderShareToRollType + " Success! " + blockEventRecorderToSaveToRoll.capturedPhotos[ blockEventRecorderToSaveToRoll.capturedPhotos.Count - 1 ] ); }
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                        else
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Photo " + recorderShareToRollType + " Failed!" ); }
                        }
                    }
                }

                //Otherwise if we're trying to save a recorded video to the camera roll
                else if( assetTypeToSaveToRoll == AssetType.Video &&
                    blockEventRecorderToSaveToRoll.recordedVideos != null && blockEventRecorderToSaveToRoll.recordedVideos.Count > 0 )
                {
                    if( recorderShareToRollType == RecorderSaveToCameraRollType.SaveFirst )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventRecorderToSaveToRoll.recordedVideos[ 0 ] ) )
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Video " + recorderShareToRollType + " Success! " + blockEventRecorderToSaveToRoll.recordedVideos[ 0 ] ); }
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                        else
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Video " + recorderShareToRollType + " Failed!" ); }
                        }
                    }
                    else if( recorderShareToRollType == RecorderSaveToCameraRollType.SaveLatest )
                    {
                        if( NatShare.SaveToCameraRoll( blockEventRecorderToSaveToRoll.recordedVideos[ blockEventRecorderToSaveToRoll.recordedVideos.Count - 1 ] ) )
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Video " + recorderShareToRollType + " Success!" + blockEventRecorderToSaveToRoll.recordedVideos[ blockEventRecorderToSaveToRoll.recordedVideos.Count - 1 ] ); }
                            if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                        }
                        else
                        {
                            if( showDebug ) { Debug.Log( "BlockEventNativeSharing.cs CallSaveToCameraRoll() Video " + recorderShareToRollType + " Failed!" ); }
                        }
                    }
                }
            }
#else
            Debug.LogError("BlockEventNativeSharing.cs CallSaveToCameraRollEvent() ERROR: Missing NATSHARE scripting define symbol under project settings");
#endif

        } //END CallSaveToCameraRollEvent
Beispiel #9
0
        /// <summary>
        /// Raises the save to camera roll button click event.
        /// </summary>
        public void OnSaveToCameraRollButtonClick()
        {
            Debug.Log("OnSaveToCameraRollButtonClick ()");

            NatShare.SaveToCameraRoll(texture);
        }