Search Unity

Native Camera for Android & iOS [Open Source]

Discussion in 'Assets and Asset Store' started by yasirkula, May 2, 2018.

  1. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Hello there,

    NativeCamera is a native Unity plugin that helps you take pictures/record videos with your device's camera on Android and iOS. It has built-in support for runtime permissions, as well.

    Asset Store: https://assetstore.unity.com/packages/tools/integration/native-camera-for-android-ios-117802
    Also available at: https://github.com/yasirkula/UnityNativeCamera
    Discord: https://discord.gg/UJJt549AaV
    GitHub Sponsors ☕

    FAQ
    • Audio is muted on iOS after calling NativeCamera.RecordVideo
    Please see: https://forum.unity.com/threads/native-camera-for-android-ios-open-source.529560/page-9#post-8207157
    • Can't use the camera, it says "java.lang.ClassNotFoundException: com.yasirkula.unity.NativeCamera" in Logcat
    If you are sure that your plugin is up-to-date, then enable Custom Proguard File option from Player Settings and add the following line to that file:
    -keep class com.yasirkula.unity.* { *; }


    Enjoy!
     
    Last edited: May 31, 2023
  2. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Now available on Asset Store!
     
    ZiadJ and omelchor like this.
  3. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Hello,

    Not able to get this to work.

    I've done:

    1. set Write Permission to External (SDCard) in Player Settings
    2. Changed my manifest according to recomendations:

    Code (CSharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest
    3.     xmlns:android="http://schemas.android.com/apk/res/android"
    4.     package="com.unity3d.player"
    5.     xmlns:tools="http://schemas.android.com/tools"
    6.     android:installLocation="preferExternal"
    7.     android:versionCode="1"
    8.     android:versionName="1.0">
    9.     <uses-feature android:name="android.hardware.camera" android:required="true" />
    10.     <supports-screens
    11.         android:smallScreens="true"
    12.         android:normalScreens="true"
    13.         android:largeScreens="true"
    14.         android:xlargeScreens="true"
    15.         android:anyDensity="true"/>
    16.  
    17.     <application
    18.         android:theme="@style/UnityThemeSelector"
    19.         android:icon="@drawable/app_icon"
    20.         android:label="@string/app_name"
    21.         android:debuggable="true">
    22.         <activity android:name="com.unity3d.player.UnityPlayerActivity"
    23.                   android:label="@string/app_name">
    24.             <intent-filter>
    25.                 <action android:name="android.intent.action.MAIN" />
    26.                 <category android:name="android.intent.category.LAUNCHER" />
    27.             </intent-filter>
    28.             <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    29.         </activity>
    30.         <provider
    31.               android:name="com.furiogames.unity.NativeCameraContentProvider"
    32.               android:authorities="furiogames"
    33.               android:exported="false"
    34.               android:grantUriPermissions="true"
    35.          </provider>
    36.     </application>
    37. </manifest>






    3. created a gameobject with this script attached:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class PicFromCamera : MonoBehaviour {
    7.  
    8.  
    9.     public Text textUIValue;
    10.  
    11.     Vector3 currentPositon = new Vector3();
    12.  
    13.     private int updateCount;
    14.  
    15.     void Update()
    16.     {
    17.         updateCount++;
    18.         textUIValue.text = "Update Count: " + updateCount.ToString();
    19.         if( Input.GetMouseButtonDown( 0 ) )
    20.         {
    21.             textUIValue.text = "Registered MouseDown";
    22.             // Don't attempt to use the camera if it is already open
    23.             if( NativeCamera.IsCameraBusy() )
    24.                 return;
    25.  
    26.             if( Input.mousePosition.x < Screen.width / 2 )
    27.             {
    28.                 // Take a picture with the camera
    29.                 // If the captured image's width and/or height is greater than 512px, down-scale it
    30.                 TakePicture( 512 );
    31.             }
    32.             else
    33.             {
    34.                 // Record a video with the camera
    35.                 RecordVideo();
    36.             }
    37.         }
    38.  
    39.         if (Input.touchCount > 0) {
    40.             textUIValue.text = "TouchCount > 0";
    41.             if( NativeCamera.IsCameraBusy() )
    42.                 return;
    43.        
    44.             Touch touch = Input.GetTouch (0); // get first touch since touch count is greater than zero
    45.             currentPositon = Camera.main.ScreenToWorldPoint (new Vector3 (touch.position.x, touch.position.y, 10));
    46.  
    47.  
    48.             if (touch.phase == TouchPhase.Began) {
    49.                 textUIValue.text = "Touch Began";
    50.  
    51.  
    52.                 if(currentPositon.x < Screen.width / 2 )
    53.                 {
    54.                     // Take a picture with the camera
    55.                     // If the captured image's width and/or height is greater than 512px, down-scale it
    56.                     TakePicture( 512 );
    57.                 }
    58.                 else
    59.                 {
    60.                     // Record a video with the camera
    61.                     RecordVideo();
    62.                 }
    63.             }
    64.  
    65.             if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) {
    66.             }
    67.  
    68.             if (touch.phase == TouchPhase.Moved) {
    69.                 textUIValue.text = "Registered Touch Began";
    70.                 if(currentPositon.x < Screen.width / 2 )
    71.                 {
    72.                     // Take a picture with the camera
    73.                     // If the captured image's width and/or height is greater than 512px, down-scale it
    74.                     TakePicture( 512 );
    75.                 }
    76.                 else
    77.                 {
    78.                     // Record a video with the camera
    79.                     RecordVideo();
    80.                 }
    81.  
    82.             }
    83.         }
    84.  
    85.     }
    86.  
    87.     private void TakePicture( int maxSize )
    88.     {
    89.         NativeCamera.Permission permission = NativeCamera.TakePicture( ( path ) =>
    90.             {
    91.                 textUIValue.text = "Image path: " + path;
    92.  
    93.                 Debug.Log( "Image path: " + path );
    94.                 if( path != null )
    95.                 {
    96.                     // Create a Texture2D from the captured image
    97.                     Texture2D texture = NativeCamera.LoadImageAtPath( path, maxSize );
    98.                     if( texture == null )
    99.                     {
    100.                         Debug.Log( "Couldn't load texture from " + path );
    101.                         return;
    102.                     }
    103.  
    104.                     // Assign texture to a temporary quad and destroy it after 5 seconds
    105.                     GameObject quad = GameObject.CreatePrimitive( PrimitiveType.Quad );
    106.                     quad.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 2.5f;
    107.                     quad.transform.forward = Camera.main.transform.forward;
    108.                     quad.transform.localScale = new Vector3( 1f, texture.height / (float) texture.width, 1f );
    109.  
    110.                     Material material = quad.GetComponent<Renderer>().material;
    111.                     if( !material.shader.isSupported ) // happens when Standard shader is not included in the build
    112.                         material.shader = Shader.Find( "Legacy Shaders/Diffuse" );
    113.  
    114.                     material.mainTexture = texture;
    115.  
    116.                     Destroy( quad, 5f );
    117.  
    118.                     // If a procedural texture is not destroyed manually,
    119.                     // it will only be freed after a scene change
    120.                     Destroy( texture, 5f );
    121.                 }
    122.             }, maxSize );
    123.  
    124.         Debug.Log( "Permission result: " + permission );
    125.     }
    126.  
    127.     private void RecordVideo()
    128.     {
    129.         NativeCamera.Permission permission = NativeCamera.RecordVideo( ( path ) =>
    130.             {
    131.                 textUIValue.text = "Video path: " + path;
    132.  
    133.                 Debug.Log( "Video path: " + path );
    134.                 if( path != null )
    135.                 {
    136.                     // Play the recorded video
    137.                     Handheld.PlayFullScreenMovie( "file://" + path );
    138.                 }
    139.             } );
    140.  
    141.         Debug.Log( "Permission result: " + permission );
    142.     }
    143. }
    144.  
    I see various debugs in editor correctly (can't access camera of course which is understandable) but on mobile the update counter just stops and nothing else when I touch screen. I assume the camera is trying to be accessed? I get a dialog asking permission and of course I grant access when app starts up.

    Using Samsung Galaxy S8, Unity 2017.1.0f3, mono 5.9.6

    Sorry for the post length but I just wanted to be thorough.

    Any ideas?

    Your Gallery asset works perfectly on device so not sure why this would not?

    Sample project is here:
    https://drive.google.com/file/d/1fyjs4MwyRH778pnS27osSSCGww07p_GN/view?usp=sharing

    Thanks!

    Joseph
     
  4. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    The only fatal issue I could spot was this:
    android:name="com.furiogames.unity.NativeCameraContentProvider"


    You shouldn't change the value of android:name (leave it as com.yasirkula.unity.NativeCameraContentProvider) because it specifies the path of the content provider class. Please let me know if that works.
     
  5. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Thanks for the response!

    I did have it as your name originally and still no go. Decided to change to mine just to see and forgot to change it back. Just changed it back to yours and still no go.

    Very strange it isn't working. Does the project I sent work for you? If so then this may be an issue with my setup in some way.
     
  6. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    The crucial part here is to move AndroidManifest.xml from Plugins/NativeCamera/Android to Plugins/Android. It is a must. Otherwise, Unity just ignores the manifest.

    I also had to change
    </provider>
    to
    />
    and tweak Update like this:

    Code (CSharp):
    1. void Update()
    2. {
    3.     updateCount++;
    4.     textUIValue.text = "Update Count: " + updateCount.ToString();
    5.     if( Input.GetMouseButtonDown( 0 ) )
    6.     {
    7.         textUIValue.text = "Registered MouseDown";
    8.         // Don't attempt to use the camera if it is already open
    9.         if( NativeCamera.IsCameraBusy() )
    10.             return;
    11.  
    12.         if( Input.mousePosition.x < Screen.width / 2 )
    13.         {
    14.             // Take a picture with the camera
    15.             // If the captured image's width and/or height is greater than 512px, down-scale it
    16.             TakePicture( 512 );
    17.         }
    18.         else
    19.         {
    20.             // Record a video with the camera
    21.             RecordVideo();
    22.         }
    23.     }
    24.        
    25.     if (Input.touchCount > 0) {
    26.         //    Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position);
    27.         textUIValue.text = "Registered TouchCount > 0";
    28.     }
    29. }
     
    shacharoz and jococo like this.
  7. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Wow! Thank you for taking your time to help with this!

    I updated to Unity 2018.1.0 made your changes, updated Android SDK (to get API level 25) and it mostly works now.

    Having a small issue with if I take a photo it isn't returning to displaying on plane. It stays at camera. If I take a second pic then it switches back to display on plane fine. It does this with vid also. I'll play with it some more.

    Thanks again!

    UPDATE: Just switched take pic/vid from screen touch to buttons and now there is no issue.
     
    Last edited: Jun 25, 2018
    shacharoz and yasirkula like this.
  8. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    That's great news! Thanks for the info.
     
  9. bawenang

    bawenang

    Joined:
    Aug 18, 2012
    Posts:
    119
    Hi, how do you grab the camera's pixels and save them to a texture like WebCamTexture but not directly to a file? I need to preview them like any camera app does.

    Thanks.
     
  10. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    NativeCamera doesn't support live preview inside Unity. Why don't you use WebCamTexture for this?
     
  11. 3dprasad

    3dprasad

    Joined:
    Aug 12, 2010
    Posts:
    6
    Hi, First, thanks a lot for making this plugin freely available. It has been really really helpful.

    I have been using this plugin successfully in iOS and android. As per our current requirement, we need as lowest resolution as possible for video recording.
    We tested on various android devices and found the lowest is 640X480. Just wanted to know if there is any way we can manually specify the resolution to go below it.
     
  12. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Unfortunately not. AFAIK, resolution only depends on EXTRA_VIDEO_QUALITY on Android and UIImagePickerController.videoQuality on iOS, and they don't accept custom resolutions. If you really need a lower resolution, you'll probably have to use another plugin that renders the camera output directly inside Unity.
     
  13. mathias_unity633

    mathias_unity633

    Joined:
    Jul 17, 2018
    Posts:
    35
    Hi, I'm getting a "Can't find ContentProvider, camera is inaccessible!"

    I didn't see anyone else post it, so trying my luck here.

    I added the provider to the manifest. Here's the code, rather simple:


    Code (CSharp):
    1.  
    2.             NativeCamera.Permission permission = NativeCamera.TakePicture((path) =>
    3.             {
    4.                 Debug.Log(path);
    5.             });
    6.  
    It does prompt for the needed permissions, but then Unity freezes after that.

    By the way, huge fan. Thanks for all the assets you have released. Probably the best asset provider I know of, up there along with the usefulness of Catlike Coding. Keep being awesome.
     
  14. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    After building your project to Android, can you check the contents of PROJECT_PATH/Temp/StagingArea/AndroidManifest.xml and verify that the provider exists? If it does exist, can I see it?
     
  15. mathias_unity633

    mathias_unity633

    Joined:
    Jul 17, 2018
    Posts:
    35
    Sure. It's the same though, except as 1 line.


    <provider android:name="com.yasirkula.unity.NativeCameraContentProvider" android:authorities="3DBear_Camera_Authority" android:exported="false" android:grantUriPermissions="true" />
     
  16. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Hmm, can you try this
    android:authorities
    : "bearcameraauth"
     
  17. mathias_unity633

    mathias_unity633

    Joined:
    Jul 17, 2018
    Posts:
    35
    Hey, sorry for wasting your time! It was a pretty obvious error on my side, I had put the snippet into an 'activity' that was under 'application'. Gotta hate the XML format... thanks for helping!
     
    yasirkula likes this.
  18. Airship

    Airship

    Joined:
    Sep 10, 2011
    Posts:
    260
    Nice job- Thank you for creating this open source plugin!
     
  19. zelmax

    zelmax

    Joined:
    Mar 16, 2018
    Posts:
    10
    Hey bros really amazing pluggin, all ok but, how can i make the image more big and more light? its little and dark. thanks
     
  20. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Is NativeCamera image smaller than an image captured via native camera app? What are their resolutions? Are there no quality settings in the camera overlay in NativeCamera?

    To decrease the darkness, you should play with the exposure settings in the camera overlay. Please note that NativeCamera simply starts the native camera app and fetches the captured image from it, the rest is up to the camera app itself.
     
  21. zelmax

    zelmax

    Joined:
    Mar 16, 2018
    Posts:
    10
    Thanks for the fast reply bro, i fixed the darkness of the picture , the only problem is after i take the picture, the image that return is too small, i have been playing with this code line

    quad.transform.localScale = new Vector3( 1f, texture.height / (float) texture.width, 1f );

    how can i do to make the image get the phone width and height? to adapt on all phones

    this is the image i get later from taking with native camera https://ibb.co/fn2v0z
     
  22. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Oh, you mean small like that, lol. I thought you were talking about the resolution of the image. The code that instantiates that small quad is for demonstration purposes only; if you want to show the image in full screen, you should ideally create a full screen RawImage object and assign the camera texture to its texture property.
     
  23. zelmax

    zelmax

    Joined:
    Mar 16, 2018
    Posts:
    10
    Bro could you be more explicit please? i did all ok but still can´t do that, image still little
     
  24. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    In essence, you can use the Texture2D texture object however you want. For example, to display the captured image in full screen, add a
    public UnityEngine.UI.RawImage rawImg;
    variable to your script and call
    rawImg.texture = texture;
    inside NativeCamera.TakePicture. Then, create a fullscreen UI-Raw Image object in your scene and assign it to the Raw Img variable of your script.
     
    zelmax likes this.
  25. zelmax

    zelmax

    Joined:
    Mar 16, 2018
    Posts:
    10
    Bro simply amazing, thanks a lot for the help, you are a nice man, cheers bro, i did it ok :D
     
  26. Sevauk

    Sevauk

    Joined:
    Oct 23, 2013
    Posts:
    2
    Hello ! I'd like to know if I can record video without on screen feedback ? I'd like to record the from camera while the user is playing.
     
  27. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Unfortunately not. This plugin can record videos with device's native camera app only.
     
  28. sskenth

    sskenth

    Joined:
    Sep 23, 2016
    Posts:
    54

    Hi I just wanted some clarity..

    First of all, thank you fro creating such amazing free assets, I'm already using the camera to take a screenshot for an AR project.

    I'd also like to add in a feature where the use can record the video feed of their AR experience on android/iso similar to the ARStickers app.

    Is there a way to record the camera feed and include the UI and AR parts? I tried to use the Record method, but the app froze maybe because the camera is already open....

    Do you have any recommendations for recording camera feed with the UI and AR... Or continuous screen recording?

    Thank you
     
  29. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    For screen recording, there are two powerful solutions:

    - Everyplay - developed by Unity team but discontinued, free, tested it myself with Vuforia AR
    - NatCorder - paid, haven't tested it myself but has a 5-star rating
     
    sskenth likes this.
  30. jkainu

    jkainu

    Joined:
    May 24, 2016
    Posts:
    3
    Hello,

    We've run into a bit of a problem on Android with 16M (5312x2988, 16:9) pictures crashing the app in the background. 12M (3984x2988, 4:3) and below seem to work fine on our test device. Currently using Unity 2018.2.8f1. The device logs seem pretty barren of anything helpful.

    iOS and video recording work fine.

    Any help or ideas would be much appreciated, thanks!
     
  31. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    If you don't do anything in NativeCamera's callback, does it still crash the app? If not, then try putting Debug.Log lines in between each line in the callback function to pinpoint the problematic line.
     
  32. jkainu

    jkainu

    Joined:
    May 24, 2016
    Posts:
    3
    The callback into Unity is never called when taking a 16M picture. If the crash happened in our app's callback function it'd be much easier to find the problem, but as it is I can't get any decent logs out. From the user's perspective, after pressing "Ok" in the camera to confirm the photo taken, the app restarts itself in the background and the callback cannot find its intended target since it doesn't exist anymore. At least that's what I'm assuming is what happens.
     
  33. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    It seems like Android OS kills Unity app to free up some memory. This happens when device runs out of memory. Please try your app on a newer device or a more powerful emulator and see if the issue persists.
     
  34. sskenth

    sskenth

    Joined:
    Sep 23, 2016
    Posts:
    54
    Thank you for the information, greatly appreciated!
     
  35. somnus_aeternam

    somnus_aeternam

    Joined:
    May 13, 2013
    Posts:
    2
    Hi,
    When using the provided TakePicture example code I witnessed the images were available in my Android's gallery. That worked for awhile, but now I no longer see the images added to gallery. I've tracked down the path on my device to see if the image exists and it appears to not be there. Maybe I'm doing something wrong, or witnessed an anomaly that should never have happened. Either way just curious if there would be a way for me to provide a path to save a captured image to the file system? Thanks
     
  36. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Images shouldn't appear in the gallery, a segment of the code is actually dedicated to deleting those images. In NativeCamera's callback function, you can copy the file to a specific path, if you want.
     
  37. somnus_aeternam

    somnus_aeternam

    Joined:
    May 13, 2013
    Posts:
    2
    Awesome thanks for the quick response. Now that i think of it I didnt see the images in the gallery using your plugin.
     
  38. baiao

    baiao

    Joined:
    Oct 8, 2018
    Posts:
    4
    Hello, everything is working great with the asset but the video that is recorded doesn't seem to be saved in memory, only the picture that is taken is being saved in device memory.
    Thanks for all the work though, great job.
     
  39. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Do you mean that NativeCamera.RecordVideo's CameraCallback returns a path that does not point to an existing file, or does it simply return null?
     
  40. ericalan

    ericalan

    Joined:
    Jun 10, 2016
    Posts:
    17
    hey, there, looking at the image properties

    Code (CSharp):
    1. #if !UNITY_EDITOR && UNITY_ANDROID
    2.         string value = AJC.CallStatic<string>( "GetImageProperties", Context, imagePath );
    3. #elif !UNITY_EDITOR && UNITY_IOS
    4.         string value = _NativeGallery_GetImageProperties( imagePath );
    5. #else
    6.         string value = null;
    7. #endif
    8.  
    9. string[] properties = value.Split( '>' );
    10. if( properties != null && properties.Length >= 4 )
    Are there any other properties accessible on that object other than the ones that are being returned? Specifically looking for the last modified date of the image.
     
  41. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Try using
    new System.IO.FileInfo(imagePath).LastWriteTime
    for this.
     
    ericalan likes this.
  42. Kultie_Kaopiz

    Kultie_Kaopiz

    Joined:
    Jun 13, 2018
    Posts:
    13
    For some reason when i use my camera feature it ask for gallery permission? Is it me or that something i don't know?
     
  43. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    NativeCamera requests WRITE_EXTERNAL_STORAGE permission (probably the cause of the gallery permission you are seeing) for two things:

    - to save the camera output to a public directory that both Unity and the camera app can access
    - to read the contents of the Gallery after an image is taken to see if a higher quality version of the captured image is saved to the Gallery instead of the specified public directory (happens for some devices) and also to detect if the camera has saved a copy of that image to the Gallery (in which case, that copy is deleted)
     
  44. Kultie_Kaopiz

    Kultie_Kaopiz

    Joined:
    Jun 13, 2018
    Posts:
    13
    Oh I see thanks for the head out ~
     
  45. shehan011

    shehan011

    Joined:
    Aug 1, 2017
    Posts:
    1
    My requirement is to get the image saved to a specific location in android mobile device. Could you tell me what specific code is dedicated to delete the images. and how am i suppose to get the images save to gallery using this plug in.
    BTW this is awesome work it has been really hepful
     
    yasirkula likes this.
  46. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    shehan011 likes this.
  47. thePortalDude

    thePortalDude

    Joined:
    Jan 9, 2017
    Posts:
    6
    Hi, thanks for your work!

    So far I literally copied and pasted the example code you made in the GitHub page and included the snippet in the AndroidManifest file but I have some issues:

    1) I debugged the "path" string and it shows me this: "/data/user/0/(my bundle id)/cache/IMG_camera.jpg but I can't find it anywhere in my device and therefore I can't find the picture file. Am I missing something?

    2) The texture attached to the quad created after the picture is taken is missing (it's pink) even though the (texture == null) check has been done. This issue might me related to the previous one, I think.

    Thanks for your help
     
    Last edited: Dec 5, 2018
  48. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Hi!

    1) It looks like an internal directory. You can copy the image file to e.g. Application.persistentDataPath, if you want to access it via the file browser. You can also use NativeGallery to save the image to gallery: https://forum.unity.com/threads/native-gallery-for-android-ios-open-source.519619/

    2) It sounds like a shader issue. If you are using a scriptable render pipeline (LWRP or HDRP), try adding a cube object to your test scene and see if it resolves the issue.
     
  49. thePortalDude

    thePortalDude

    Joined:
    Jan 9, 2017
    Posts:
    6
    I managed to save the image into the gallery using both persistent data path and your NativeGallery plugin, thanks! I am trying to do the same with videos but I can't find a way to save the video recorded as data (I used File.WriteAllBytes to save the texture2D of the picture). Is there something like the NativeCamera.LoadImageAtPath(path) method I can use to do the trick?

    EDIT: Ok, I just needed to call the ShareVideoToGallery using the path given by NativeCamera plugin, solved :)
     
    Last edited: Dec 6, 2018
    yasirkula likes this.
  50. ironbitUnity

    ironbitUnity

    Joined:
    Jun 29, 2017
    Posts:
    11
    Hi, when I run the function RecordVideo my phone freeze, and I have to finish the app, it's something extra that I need to do? or I have to configure something in the code, thanks.

    Code (CSharp):
    1. private void RecordVideo(){
    2.         NativeCamera.Permission permission = NativeCamera.RecordVideo((AndroidPath) => {
    3.             if(AndroidPath != null){
    4.                 Handheld.PlayFullScreenMovie("file://"+AndroidPath);
    5.             }
    6.         });
    7.     }
    In the Logcat show this message: Can't find ContentProvider, camera is inaccessible!
     
    Last edited: Dec 6, 2018