Search Unity

Native Gallery for Android & iOS [Open Source]

Discussion in 'Assets and Asset Store' started by yasirkula, Feb 28, 2018.

  1. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,024
    With this Unity Asset just disable UI before start recording.
     
    LYNXS_ likes this.
  2. LYNXS_

    LYNXS_

    Joined:
    Mar 30, 2019
    Posts:
    2
    thank you, will try this :)
     
    makaka-org likes this.
  3. jbhere

    jbhere

    Joined:
    Apr 10, 2020
    Posts:
    6
    hi, i'm a beginner with unity and this is exactly the thing i was trying to find

    but for some reason i can't import or use it in c#
    i tried "using NativeGallary" and a few other ideas but none worked

    it seems like there is just something i'm missing

    what am i supposed to "using"
     
  4. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You don't need any
    using
    lines. Just call NativeGallery functions from your scripts. Check out the example code to learn more.
     
    makaka-org likes this.
  5. jbhere

    jbhere

    Joined:
    Apr 10, 2020
    Posts:
    6
    thank you so much!
     
    yasirkula likes this.
  6. fujiconsys

    fujiconsys

    Joined:
    Oct 27, 2020
    Posts:
    2
    Hi yasirkua! Thank you for the great assets.
    I am in trouble.
    I have a following error in Logcat when NativeGallery.SaveImageToGallery() is executed on Android.
    Could you help me ?


    2021/02/07 00:36:11.742 10946 10968 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.yasirkula.unity.NativeGalleryPermissionReceiver
    2021/02/07 00:36:11.742 10946 10968 Error Unity java.lang.ClassNotFoundException: com.yasirkula.unity.NativeGalleryPermissionReceiver
    2021/02/07 00:36:11.742 10946 10968 Error Unity at java.lang.Class.classForName(Native Method)
    2021/02/07 00:36:11.742 10946 10968 Error Unity at java.lang.Class.forName(Class.java:454)
    2021/02/07 00:36:11.742 10946 10968 Error Unity at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    2021/02/07 00:36:11.742 10946 10968 Error Unity at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
    2021/02/07 00:36:11.742 10946 10968 Error Unity at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
    2021/02/07 00:36:11.742 10946 10968 Error Unity at android.os.Handler.dispatchMessage(Handler.java:103)
    2021/02/07 00:36:11.742 10946 10968 Error Unity at android.os.Looper.loop(Looper.java:214)
    2021/02/07 00:36:11.742 10946 10968 Error Unity at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
    2021/02/07 00:36:11.742 10946 10968 Error Unity Caused by: java.lang.ClassNotFoundException: com.yasirkula.unity.NativeGalleryPermissionReceiver
    2021/02/07 00:36:11.742 10946 10968 Error Unity ... 8 more
    2021/02/07 00:36:11.742 10946 10968 Error Unity at UnityEngine.AndroidJNISafe.CheckException () [0x00091] in <157db3d40e194fc2b8370dbe68a88be2>:0
    2021/02/07 00:36:11.742 10946 10968 Error Unity at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x0000f] in <157db3d40e194fc2b8370dbe68a88be2>:0
    2021/02/07 00:36:11.742 10946 10968 Error Unity at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.St


    Unity : 2019.2.21f1
    Android : Android 10

    I'm sorry about my poor English.
     
  7. WillieJr1991

    WillieJr1991

    Joined:
    Nov 21, 2014
    Posts:
    9
    Hello, we are having an issue with Xcode.

    We built and tested our game for android successfully using this plugin, but when building for iOS we ran into an error.

    After building to iOS from Unity successfully, opening up Xcode, and building in Xcode, we get these 2 errors right before the end:
    1. incompatible pointer types assigning to 'id<UINavigationControllerDelegate,UIImagePickerControllerDelegate> _Nullable' from 'Class' imagePicker.delegate = self;
    2. incompatible pointer types assigning to 'id<UIPopoverControllerDelegate> _Nullable' from 'Class' popup.delegate = self;
    Is there something I need to do on the unity side or the Xcode side?

    Also uploaded a screenshot below.
     

    Attached Files:

  8. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Updating the plugin to the latest version should resolve the issue.
     
    makaka-org likes this.
  9. WillieJr1991

    WillieJr1991

    Joined:
    Nov 21, 2014
    Posts:
    9
    We built it with version 1.6.2 when the errors popped up for us.
     
  10. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    But the native code isn't the same. I'd recommend you to delete the plugin and reimport it.
     
  11. WillieJr1991

    WillieJr1991

    Joined:
    Nov 21, 2014
    Posts:
    9
    We were able to fix the issue by removing the plugin and re-importing the plugin from your GitHub. We have be importing the one from the Unity Asset Store which had different code from the GitHub for some reason.

    But it now works using the code from GitHub, thank you.
     
    makaka-org likes this.
  12. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I keep the Asset Store version synchronized with GitHub version. I've just downloaded the plugin from Asset Store and can verify that it is the latest version. I'm uploading my assets with Unity 2018.4, perhaps if you are using an older Unity version, you can't download those newer Native Gallery versions?
     
  13. WillieJr1991

    WillieJr1991

    Joined:
    Nov 21, 2014
    Posts:
    9
    I see. Well, just for reference, we are currently using 2020.2.2f1 and even in the Package Manager the downloaded and imported version I have was 1.6.2. It was weird, but regardless we got it working now.
     
    yasirkula likes this.
  14. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Please see the relevant FAQ entry.
     
  15. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,024
    Hi, is it possible to set the description of permission when I ask for it? (as a parameter of a function, not in your NCPostProcessBuild.cs)
     
  16. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,024
    I use the both Native Gallery & Native Camera.

    I have "This app saves videos to your Photo Library." description in the app, but in NGPostProcessBuild.cs there is no such text in both plugins.

    So how can I change it from Unity (not from Xcode)?

    P.S. I got rejection from Apple. So your default texts need to be improved.

    "
    Guideline 5.1.1 - Legal - Privacy - Data Collection and Storage


    We noticed that your app requests the user’s consent to access the photos and camera, but doesn’t sufficiently explain the use of the photos and camera in the purpose string.

    To help users make informed decisions about how their data is used, all permission request alerts need to specify how your app will use the requested information.

    Next Steps

    Please revise the relevant purpose string in your app’s Info.plist file to specify why your app needs access to the user's photos and camera. Make sure the purpose string includes an example of how the user's data will be used.

    You can modify your app's Info.plist file using the property list editor in Xcode.

    Resources

    - See examples of helpful, informative purpose strings.
    - Review a list of relevant property list keys.
    "
     
    Last edited: Feb 13, 2021
  17. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    But as you said, "This app saves videos to your Photo Library." string (the string that caused the rejection) doesn't come from NativeGallery or NativeCamera. You can search that string in entire project via CTRL+Shift+F in Visual Studio, another plugin might be adding that string.

    I don't know if we can change Info.plist strings at runtime (passing the description as a parameter to a function).
     
  18. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,024
    Awesome. Thank you. The string was set by Cross Platform Replay Kit.

    2 things caused the rejection. 2nd (Native Camera) is: "The app requires access to the camera to take pictures or record videos with it.";
     
    yasirkula likes this.
  19. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    It may not be possible to find a better description for NativeCamera that isn't app-specific (i.e. generic enough that it applies to every NativeCamera-integrated app's camera usage).

    Also I think that only a portion of app reviewers reject this description because I haven't heard about app rejections in a long while. Customizing the camera usage description is of course a great thing but if you are lucky, your app reviewer won't be bothered with the generic description.
     
  20. MohsenJamaliL

    MohsenJamaliL

    Joined:
    Nov 13, 2017
    Posts:
    12
    Hi yasirkua! Thank you for creating this asset.

    I have a problem with permission request. Why does it request permission in the app start?
    I want to move the permission request to the actual upload. But whatever I do it asks for the permission in the beginning

    thanks in advance
     
  21. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  22. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,024
    Approved Descriptions are next (based on Apple examples):

    Privacy - Photo Library

    Enable AR Masker to access your camera roll to upload your Photos and save ones you've taken with the app.

    Privacy — Camera Usage

    Enable AR Masker to access your camera to Take Photos and Record Videos when you are making creative content with the app.
     
    yasirkula likes this.
  23. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Thanks for sharing, these are useful references.
     
    makaka-org likes this.
  24. MohsenJamaliL

    MohsenJamaliL

    Joined:
    Nov 13, 2017
    Posts:
    12
    Thank you Yasirkula, It worked for me.
     
    yasirkula likes this.
  25. itsnottme

    itsnottme

    Joined:
    Mar 8, 2017
    Posts:
    129
    Hey, thank you for the great asset.

    I have 2 questions, if you don't mind.

    1. How do I allow 2 image types when using GetImageFromGallery, for example png and jpg. The documentation only shows either all or a single image type.

    2. Is it possible to find out what image type I got from GetImageFromGallery?

    Thanks.
     
  26. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    1. You can either allow 1 image type or all image types (leaving mime argument as is). I'd recommend you to allow all image types because LoadImageAtPath should be able to load all of them.
    2. You need to check the returned image's file extension.
     
    itsnottme likes this.
  27. baeyoung

    baeyoung

    Joined:
    Aug 6, 2019
    Posts:
    1
    Hi yasirkua! Thank you for creating this asset.

    I Have a problem IOS14

    2021-02-25 17:18:54.074864+0900 test[4661:2455445] AVDRegister - AppleAVD HEVC codec registered
    2021-02-25 17:18:54.075056+0900 test[4661:2455445] AVDRegister - AppleAVD H264 codec registered
    2021-02-25 17:18:54.075144+0900 test[4661:2455445] AVDRegister - AppleAVD Leghorn codec registered
    libpng error: [00][00][00][00]: missing IHDR

    LoadImageAtPath -> Texture2D 8X8
     
  28. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Can you explain what is happening?
     
  29. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    Yas, is there a way to limit video record time? I want to be able to only allow the use to record 30s videos. Once the 30 second hits stop the video recording. Is this possible? I figured it would be something to do with the frame callback?
     
  30. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  31. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    Yes that's what I was looking for. Native cam. Just realized I posted this in native gallery. My bad yas.
     
  32. ImNewAtThis

    ImNewAtThis

    Joined:
    Feb 8, 2016
    Posts:
    10
    I'm working from your example code, trying to take a screenshot. I'm calling the Take Screenshot and Save Coroutine from a public void attached to a UI button. When I build to my android device and press the button it doesn't save the screenshot. I have the Write Permission set to external in the project settings. I've looked everywhere on the device that an image could be stored and I can't find it. Is Native Gallery setup to work as soon as it's imported or have I missed a setup step?
     
  33. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You haven't missed a step. I'd recommend you to first check out FAQ in the main post. If it doesn't help, you should see if there are any error messages in logcat.
     
  34. ImNewAtThis

    ImNewAtThis

    Joined:
    Feb 8, 2016
    Posts:
    10
    These errors spawned in logcat when I pressed the button to screenshot.

    2021/03/10 16:03:59.319 11672 21373 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.yasirkula.unity.NativeGalleryPermissionReceiver
    2021/03/10 16:03:59.319 11672 21373 Error Unity java.lang.ClassNotFoundException: com.yasirkula.unity.NativeGalleryPermissionReceiver
    2021/03/10 16:03:59.319 11672 21373 Error Unity at java.lang.Class.classForName(Native Method)
    2021/03/10 16:03:59.319 11672 21373 Error Unity at java.lang.Class.forName(Class.java:454)
    2021/03/10 16:03:59.319 11672 21373 Error Unity at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    2021/03/10 16:03:59.319 11672 21373 Error Unity at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
    2021/03/10 16:03:59.319 11672 21373 Error Unity at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
    2021/03/10 16:03:59.319 11672 21373 Error Unity at android.os.Handler.dispatchMessage(Handler.java:103)
    2021/03/10 16:03:59.319 11672 21373 Error Unity at android.os.Looper.loop(Looper.java:214)
    2021/03/10 16:03:59.319 11672 21373 Error Unity at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
    2021/03/10 16:03:59.319 11672 21373 Error Unity Caused by: java.lang.ClassNotFoundException: Didn't find class "com.yasirkula.unity.NativeGalleryPermissionReceiver" on path: DexPathList[[zip file "/data/app/com.Noho.SlieveAR2-Fu6gBLwR5I7mB_-nxP98aQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.Noho.SlieveAR2-Fu6gBLwR5I7mB_-nxP98aQ==/lib/arm, /data/app/com.Noho.SlieveAR2-Fu6gBLwR5I7mB_-nxP98aQ==/base.apk!/lib/armeab


    I can't see anything in the FAQ relating to those errors.
     
  35. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Quoting from the FAQ :D
     
  36. ImNewAtThis

    ImNewAtThis

    Joined:
    Feb 8, 2016
    Posts:
    10
    Apologies. I thought ProGuard was something I would have had to add to the project, I didn't know it was a built in feature. Thanks for your patience, I'll give that a go.
     
    yasirkula likes this.
  37. ImNewAtThis

    ImNewAtThis

    Joined:
    Feb 8, 2016
    Posts:
    10
    Thanks for your help yesterday. I added that to the proguard filters but I'm still encountering the same errors. I must have missed something in setting up the proguard filters. Is there more to it than adding that filter to the text file?
     
  38. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    There isn't. You just enable Custom ProGuard File and add the line to the file. Make sure that Minification in Player Settings is set to either None or ProGuard and not Gradle.
     
  39. ImNewAtThis

    ImNewAtThis

    Joined:
    Feb 8, 2016
    Posts:
    10
    I've double checked all of that and tried building with the Minification set to None and then to ProGuard. I'm still getting the same errors when I try to take a Screenshot.
     
  40. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I'm sorry to hear that. Unity must be somehow ignoring your custom ProGuard filters then. I haven't heard about this issue before but I'd recommend you to google it and see if it can possibly be the case. You can also test the plugin on a new Unity project and figure out which other plugin or Player Settings might be causing this issue via trial & error.
     
  41. ImNewAtThis

    ImNewAtThis

    Joined:
    Feb 8, 2016
    Posts:
    10
    Thanks, I'll give that a go
     
    yasirkula likes this.
  42. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    @yasirkula , is there a way to limit orientation? Like when recording a video can i limit the camera orientation to portrait only?
     
  43. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Unfortunately not. NativeCamera doesn't implement its own camera functionality, it invokes external camera apps. There isn't a way to customize these apps' behaviour most of the time.
     
  44. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    Am I correct in thinking the LoadImageAtPath function won't apply exif rotation in the editor, but will on mobile platforms? or is exif orientation not supported
     
  45. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Exif orientation will be applied on mobile but not on the Editor, you are correct. There is no way to fetch rotation info from image without using 3rd party dependencies on Editor and I didn't really bother with that since the asset is designed for Android & iOS only.
     
    ROBYER1 and nilsdr like this.
  46. Pranav_Redstoneinvente

    Pranav_Redstoneinvente

    Joined:
    Apr 13, 2018
    Posts:
    121
    Hi, I am running into a problem where nothing happens when I request to load an image, when i test it in the editor, i get a proper way to load an image but in the android player, nothing happens. Storage permissions granted
     
  47. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Please check logcat logs and see if there are any error messages there. I'm guessing that ProGuard is enabled in your project in which case you should check out the related entry in FAQ (main post).
     
  48. Pranav_Redstoneinvente

    Pranav_Redstoneinvente

    Joined:
    Apr 13, 2018
    Posts:
    121
    Hi, where can i find the logcat logs?
     
  49. Pranav_Redstoneinvente

    Pranav_Redstoneinvente

    Joined:
    Apr 13, 2018
    Posts:
    121
    And also, if the project does indeed uses ProGuard, where should i include this:
    -keep class com.yasirkula.unity.* { *; }
    ?Thanks
     
  50. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You can use Unity's "Android Logcat" package. To add the filter, you first need to enable Custom ProGuard File in Player Settings. Then add the filter to that file.