Search Unity

Native Gallery for Android & iOS [Open Source]

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

  1. intaj_cse

    intaj_cse

    Joined:
    Nov 25, 2014
    Posts:
    10
    HI yasirkula , I have implemented you plugin and all the setting , i am getting this error ,
    2020-06-01 15:51:08.188 24759-24836/com.adda52.rummyapp.dev E/Unity: AndroidJavaException: java.lang.ClassNotFoundException: com.yasirkula.unity.NativeGallery
    java.lang.ClassNotFoundException: com.yasirkula.unity.NativeGallery
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:453)
    at java.lang.Class.forName(Class.java:378)
    at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
    at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source:72)
    at android.os.MessageQueue.next(MessageQueue.java:395)
    at android.os.Looper.loop(Looper.java:160)
    at com.unity3d.player.UnityPlayer$e.run(Unknown Source:32)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.yasirkula.unity.NativeGallery" on path: DexPathList[[zip file "/data/app/com.adda52.rummyapp.dev-t6HqCaurdHyazeNTb_h_zg==/base.apk"],nativeLibraryDirectories=[/data/app/com.adda52.rummyapp.dev-t6HqCaurdHyazeNTb_h_zg==/lib/arm, /data/app/com.adda52.rummyapp.dev-t6HqCaurdHyazeNTb_h_zg==/base.apk!/lib/armeabi-v7a, /s
    2020-06-01 15:51:09.778 24759-24863/com.adda52.rummyapp.dev E/mono: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
    at UnityEngine.AndroidJavaObject.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
    at UnityEngine.AndroidJavaObject.Finalize () [0x00000] in <filename unknown>:0

    kindly help me out as soon as possible.
    my project use -
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'

    so I added
    -keep class com.yasirkula.unity.* { *; }

    to my proguard-unity.txt;

    its not working for me :(
    waiting for your response
     
  2. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Does setting Minification to None fix this issue?
     
  3. intaj_cse

    intaj_cse

    Joined:
    Nov 25, 2014
    Posts:
    10
    NO
     
  4. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    It may not be ProGuard related then. I'd recommend you to remove the plugin from your project and reimport it from GitHub: https://github.com/yasirkula/UnityNativeGallery/#installation. If that doesn't change anything, check if Android platform is selected in Plugins/NativeGallery/Android/NativeGallery.jar's import settings in the Inspector. If it is, I don't really know what is causing this issue.
     
  5. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    165
    I really can't find anything specific in the logcat about it, it only crashes when using your plugin :/
     
  6. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    165
    It crashes without even choosing a pic, exactly when the choosing pic intent menu opened
     
  7. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    As much as I want to help, I don't know what else would cause this issue.
     
  8. Prayyogo

    Prayyogo

    Joined:
    Jul 28, 2016
    Posts:
    1
    Hello can your plugin get picture from camera?
     
  9. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    165
    I started a new scene, the app doesn't crush, but every time I run GetImageFromGallery(), the app loses its focus and I go back to lock screen! When I unlock my phone I can see the menu "Select a PNG image" and I can select the image and go back to the scene where I left, the functionality seems to work fine but why does it take me out to the lock screen?
     
  10. jokigenki

    jokigenki

    Joined:
    Jul 19, 2014
    Posts:
    41
    Hi, thank you for producing this library, it's saved me a lot of time :) I've just got a request from my client that they'd like to be able to specify a date range, and get the images between those dates. I've checked the native implementations for both iOS and Android and they support this functionality. I'm happy to add the methods myself but how can I access the internals of the jar file?

    Ref:

    iOS: https://stackoverflow.com/questions...hoto-library-within-range-of-two-dates-in-ios
    Android: https://stackoverflow.com/questions/18318882/android-filter-gallery-results-date-range
     
    Last edited: Jun 2, 2020
  11. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @Prayyogo You can use NativeCamera for that: https://forum.unity.com/threads/native-camera-for-android-ios-open-source.529560

    @shlighter It shouldn't, I haven't programmed it to do so. I don't encounter these issues on my S8, perhaps another plugin is somehow affecting NativeGallery? You can create a new Unity project and see if it also suffers from the same issues.

    @jokigenki JAR source code is available at: https://github.com/yasirkula/UnityNativeGallery/tree/master/.github/JAR Source. But the solutions you've linked don't use UIImagePickerController on iOS or the ACTION_IMAGE_CAPTURE intent on Android, so they don't use Gallery's native UI; you'd have to create your own native UI.
     
    jokigenki likes this.
  12. intaj_cse

    intaj_cse

    Joined:
    Nov 25, 2014
    Posts:
    10
    Hi I resolve the classNotFountException . but the i am getting this while trying to fetch image .
    Unity: Timeout while trying to pause the Unity Engine.

    Is there any solution for this.
     
  13. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    This happens to me as well, it doesn't break the functionality of the plugin so you can ignore it.
     
  14. AikiroKun

    AikiroKun

    Joined:
    Jan 31, 2018
    Posts:
    1
    So I have the same problem but only sometimes. When selecting a image or photo.The app loses its focus and restarts the app..
     
    Last edited: Jun 3, 2020
  15. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    165
    @shlighter It shouldn't, I haven't programmed it to do so. I don't encounter these issues on my S8, perhaps another plugin is somehow affecting NativeGallery? You can create a new Unity project and see if it also suffers from the same issues.

    I only use your plugin and it's a new project, every time I run GetImageFromGallery(), the app goes back to lock screen. But it's working fine after I unlock the phone and continue to choose a pic from the gallery
     
  16. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @AikiroKun Other than the RAM-related restarts I've mentioned, I don't know why it would happen. It's likely caused by device running out of RAM.

    @shlighter I can't reproduce this issue on my own S8 and googling "action_pick locks screen", "action_pick locks phone", "action_get_content locks screen" and ""action_get_content locks phone" doesn't yield anything. You must understand that I don't have anything useful to pinpoint this issue (that is, if it is caused by NativeGallery and not something else like a misbehaving native Android app, virus, corrupt rooted phone). You can check out the Android source code yourself to verify that NativeGallery doesn't have any lock screen related code there: https://github.com/yasirkula/UnityNativeGallery/tree/master/.github/JAR Source
     
  17. intaj_cse

    intaj_cse

    Joined:
    Nov 25, 2014
    Posts:
    10
    Thank you sir for this package.
    I want to select more than one type of image , how to do that ?
    currently there is only one type we can put like . mime : image/png
    i want to select only png and jpg and jpeg types at the same time.
    kindly help me
     
  18. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Sadly, multiple mime types aren't possible. You can leave mime as "image/*" to select all image types. NativeGallery.LoadImageAtPath should be able to convert any image in the gallery to Texture2D.
     
  19. intaj_cse

    intaj_cse

    Joined:
    Nov 25, 2014
    Posts:
    10
    Hi @yasirkula is there any way to select image as well as .pdf
     
  20. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  21. BigRedGames

    BigRedGames

    Joined:
    Jun 25, 2016
    Posts:
    48
    Hello @yasirkula . I'm wonder if there is a way to show the request permission popup on iOS even if the user didn't allow before. I mean, I want to show this popup again and again on the button click event if the user didn't allow yet.
     
  22. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You can't ask the permission twice on iOS (here's one of the numerous stackoverflow entries about this topic). But you can call the NativeGallery.OpenSettings() function to launch Settings, then user can grant the permission from there.
     
    BigRedGames likes this.
  23. tjPark

    tjPark

    Joined:
    Mar 19, 2015
    Posts:
    13
    I just thought that, NativeGallery.LoadImageAtPath()'s third parameter as false = nonreadable and true = readable.. but it wasn't.

    I am always super happy with all your products(your codes are the one best in assetstore). I'm sending you coffee today, have a greate day!
     
    yasirkula likes this.
  24. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Thank you for your support :)
     
  25. alvaro-em

    alvaro-em

    Joined:
    Feb 23, 2012
    Posts:
    77
    Hi,@yasirkula ! We are trying to load an image from the iOS Gallery, but we are having this error:

    libpng error: [00][00][00][00]: missing IHDR

    iOS version is 13.4.1. We have tried both screenshots and pictures taken directly with the iOS Camera app and both fail with that error. We are using "NativeGallery.LoadImageAtPath". We have found out that images and screenshots taken with former versions of iOS work like a charm.

    Can you give us a clue about what might be happening? I have found another user having this issue, but not solution was given to his problem. It looks like it is related to libpng.
     
  26. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Unfortunately, I still don't know the cause of the issue. Googling the error doesn't yield anything useful and I'm not manually using libpng anywhere in the source code. You may have to use Texture2D.LoadImage as a workaround :/
     
  27. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    165
    Hey, I know it's not the purpose of the asset, but I'm really stuck - Once I load a video from the gallery- I receive a path, I can play it with videoplayer.url = path . Is there a way I can cut this video (let's say cut it to play only 3 seconds) then save it back on mobile / edit the byte array?
     
  28. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    NativeGallery doesn't support editing the original file. If you call SaveVideoToGallery, it will be saved as a separate file.

    P.S. SimpleFileBrowser does support overwriting files but it doesn't have the fancy Gallery UI and it can't be used to browse Gallery contents on iOS: https://github.com/yasirkula/UnitySimpleFileBrowser/
     
  29. upeter4

    upeter4

    Joined:
    Jun 29, 2020
    Posts:
    1
    Hi there, is it possible to get a thumbnail from a video in the gallery? Like they have in Mobile Media Picker asset? Even if it's just the first frame? Or do you know how to do it in addition to your code? Thanks!!
     
  30. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    It isn't supported and I haven't researched about this topic, so unfortunately I don't know the requirements and APIs for this task.
     
  31. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    can it pick music files? like mp3
     
  32. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    This function might work on Android, so you can try making it public and calling it. But it is not supported on iOS and it is only there for experimental purposes, so I don't provide support for it.
     
  33. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Im trying to understand why its so hard to get access to the gallery? What's the big deal with it? Dont they want programs to be able to provide users with the ability to access their gallery of images and videos?

    Im having such a hard time with it. my phone upgraded to android 10 by itself last night, now my app is broken, it can no longer access the gallery. For example here is the error

    im trying to access a video file from the gallery at path

    /storage/emulated/0/DCIM/Camera/852a80b83ae7245ad91a06539bede22a.mp4

    but when i try to open i get this error, any idea how i can fix?

    2020-07-05 13:21:54.247 30631-30742/? E/Unity: UnauthorizedAccessException: Access to the path "/storage/emulated/0/DCIM/Camera/852a80b83ae7245ad91a06539bede22a.mp4" is denied.
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00000] in <00000000000000000000000000000000>:0
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <00000000000000000000000000000000>:0
    at MyUtil+<pUploadFile>d__216.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0
    at UploadImageOrVideo.Upload (System.String path, System.String ext) [0x00000] in <00000000000000000000000000000000>:0
    at UploadImageOrVideo+<DoImportVideo>d__22.Mov
     
    Last edited: Jul 5, 2020
  34. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I'd say that it was for security purposes. Malicious apps can access&upload these media files to their own servers without users knowing about it. With the new Storage Access Framework system, users select which files an app can access to, app can't access other files without permission.

    From a user's perspective, I find this approach a lot more secure (I believe any user would think likewise). From a developer's perspective, it means more work so I understand the frustration.

    Regardless, the Android team probably received enough complaints about this topic and took a step backwards. I've answered your other message here, it should provide more info.
     
  35. troitskiyigorrf

    troitskiyigorrf

    Joined:
    Jul 2, 2020
    Posts:
    4
    Hi, i have some problems. I cant call methods from NativeGallery class. It says, that the name doesn't exist in the context. Maybe i'am doing something wrong? I'll be glad, if someone could help me.
    upload_2020-7-6_22-42-1.png
    upload_2020-7-6_22-43-52.png
     
  36. thetomatodev

    thetomatodev

    Joined:
    Apr 20, 2020
    Posts:
    11
    Hi @yasirkula I am fairly new to unity and this maybe a trivial question to ask. I created an empty project and when I load select an image from my gallery, I can only see a square of the given size. How can I see the picture I selected?
     
  37. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @troitskiyigorrf Never seen something like that before and honestly don't know what is causing it. If the following line doesn't yield an error in Unity's console, then you can simply ignore the issue with Visual Studio and type the functions without relying on auto-complete:
    NativeGallery.SaveImageToGallery( null, "GalleryTest", "Image.png" )


    @thetomatodev Could you share a screenshot of the issue and describe in more detail where you want to see the selected picture?
     
  38. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I've added NativeGallery.GetVideoThumbnail function and updated the GitHub repository: https://github.com/yasirkula/UnityNativeGallery/. Hope it helps!
     
  39. RendergonPolygons

    RendergonPolygons

    Joined:
    Oct 9, 2019
    Posts:
    98
    Hello @yasirkula

    Thanks so much for this great asset !! I've use it for quite sometime in Android and iOS. I can take a snapshot and save the image successfully in iOS. However I'm having difficulties accessing the Gallery to pick an image, can you please give me some guidance?

    Im building for iOS, iPad Pro 2018, iOS 13.5.1, Unity 2019.4.1f1, April 9th Native Gallery version.

    When I execute PickImage function as per example code here , I get the error below. However the gallery opens:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object.
    2.   at C_CreateAccount.PickImage () [0x00000] in <00000000000000000000000000000000>:0
    3.   at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    4.   at UnityEngine.Events.InvokableCall.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    5.   at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    6.   at UnityEngine.UI.Button.Press () [0x00000] in <00000000000000000000000000000000>:0
    7.   at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00000] in <00000000000000000000000000000000>:0
    8.   at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0
    9.   at UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1].Invoke (T1 handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0
    10.   at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00000] in <00000000000000000000000000000000>:0
    11.   at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, System.Boolean pressed, System.Boolean released) [0x00000] in <00000000000000000000000000000000>:0
    12.   at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () [0x00000] in <00000000000000000000000000000000>:0
    13.   at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00000] in <00000000000000000000000000000000>:0
    14.   at UnityEngine.EventSystems.EventSystem.Update () [0x00000] in <00000000000000000000000000000000>:0
    15. UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
    16. UnityEngine.DebugLogHandler:LogException(Exception, Object)
    17. UnityEngine.Logger:LogException(Exception, Object)
    18. UnityEngine.Debug:LogException(Exception)
    19. UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    20. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
    21. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
    22. UnityEngine.EventSystems.StandaloneInputModule:Process()
    23. UnityEngine.EventSystems.EventSystem:Update()
    24.  
    From what I could track on debug.log, the null ref exception occurs in Permission GetMediaFromGallery in the Unity_IOS section executed.


    Then, if I tap on an image in the gallery, the error below happens:
    Code (CSharp):
    1.  
    2. ArgumentException: Texture '' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings.
    3.   at UnityEngine.ImageConversion.EncodeToJPG (UnityEngine.Texture2D tex, System.Int32 quality) [0x00000] in <00000000000000000000000000000000>:0
    4.   at UnityEngine.ImageConversion.EncodeToJPG (UnityEngine.Texture2D tex) [0x00000] in <00000000000000000000000000000000>:0
    5.   at C_CreateAccount+<>c__DisplayClass21_0.<PickImage>b__0 (System.String path) [0x00000] in <00000000000000000000000000000000>:0
    6.   at NativeGallery+MediaPickCallback.Invoke (System.String path) [0x00000] in <00000000000000000000000000000000>:0
    7.   at NativeGalleryNamespace.NGMediaReceiveCallbackiOS.OnMediaReceived (System.String path) [0x00000] in <00000000000000000000000000000000>:0
    I tried iOS manual setup as per this help page. I also tried NGPostProcessBuild set to true and setting Additional usage instead as per this link.

    My code fired by button when clicked by user:
    Code (CSharp):
    1. public void PickImage()
    2.     {
    3.         int maxSize = 1024;
    4.  
    5.         NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
    6.         {
    7.             Debug.Log("Image path: " + path);
    8.             if (path != null)
    9.             {
    10.                 // Create Texture from selected image
    11.                 Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
    12.                 if (texture == null)
    13.                 {
    14.                     Debug.Log("Couldn't load texture from " + path);
    15.                     return;
    16.                 }
    17.                 else
    18.                 {
    19.                     imgByteArray = texture.EncodeToJPG();
    20.                 }
    21.             }
    22.         }, "Select an image", "image");
    23.  
    24.         Debug.Log("Permission result: " + permission + " byte img size " + imgByteArray.Length);
    25.     }
    Thanks a bunch for your help
     
  40. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    The first error is caused by imgByteArray.Length at line 24. GetImageFromGallery is an asynchronous function, so imgByteArray is assigned value only after user selects an image in Gallery.

    The second error can be resolved by setting the markTextureNonReadable parameter of LoadImageAtPath to false.
     
    Tarrag likes this.
  41. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    215
    Hi @yasirkula thank you so much for your response !
    In regards to the nullreference exception, I'm sorry, I don't understand what I'm doing wrong, I'm using your code PickImage and it makes sense to me because we first check if texture==null and if so return, else assign texture to imgByteArray.

    I'm sorry if it's a newbie question but can't figure out what is wrong as it makes sense and follows your github example? I removed the "else" in my code to make it more similar to yours but nullref exception continues to occur.

    markTextureNonReadable worked great :)

    Thanks a bunch for your help
     
  42. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    This should work:

    Code (CSharp):
    1. public void PickImage()
    2. {
    3.     int maxSize = 1024;
    4.  
    5.     NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
    6.     {
    7.         Debug.Log("Image path: " + path);
    8.         if (path != null)
    9.         {
    10.             // Create Texture from selected image
    11.             Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
    12.             if (texture == null)
    13.             {
    14.                 Debug.Log("Couldn't load texture from " + path);
    15.                 return;
    16.             }
    17.             else
    18.             {
    19.                 imgByteArray = texture.EncodeToJPG();
    20.                
    21.                 // This code is asynchronous, so it runs AFTER the "Permission result" line
    22.                 // You must use imgByteArray here, not down there
    23.                 Debug.Log("Byte img size " + imgByteArray.Length);
    24.             }
    25.         }
    26.     }, "Select an image");
    27.  
    28.     Debug.Log("Permission result: " + permission);
    29. }
     
    Tarrag likes this.
  43. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    215
    Thanks a ton , it works great @yasirkula !!

    I see now how it works, really appreciate your support :)
    Cheers!
    p.s. - fyi i think your Unity Assets Store page link in your signature is broken
     
    Last edited: Jul 13, 2020
    yasirkula likes this.
  44. UniBitDeveloper

    UniBitDeveloper

    Joined:
    Jul 17, 2017
    Posts:
    19
    hi i have video and i want get Thumbnail and save as screenshot
    Texture2D _lastPhotoTexture = NativeGallery.GetVideoThumbnail(path); - no problem
    byte [] bytes = _lastPhotoTexture.EncodeToPNG(); - problem, texture(_lastPhotoTexture ) is not redable
    Help pls @yasirkula .

    texture is not readable the texture memory can not be accessed from scripts
     
  45. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You can change this line as follows:
    return LoadImageAtPath( thumbnailPath, maxSize, false );
     
  46. sotrosh

    sotrosh

    Joined:
    Dec 25, 2014
    Posts:
    13
    Is there is a way to record video of the screen and save to album using NativeGallery.SaveVideoToGallery() function?
    Thank you.
     
  47. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    NativeGallery doesn't have screen recording functionality. You can use Everyplay (free but discontinued), NatCorder (paid) or the other assets on Asset Store to record the screen. Then, you can simply pass the video file's path to NativeGallery.SaveVideoToGallery.
     
    sotrosh likes this.
  48. Sashimiii

    Sashimiii

    Joined:
    Sep 26, 2017
    Posts:
    15
    Hi Yasirkula,
    I have downloaded your plugin and it works nicely, thank you so much. However, I was wondering whether the camera capture can be rendered on an object? I would like to implement this on an interface, so I really hope it is possible :)!
     
  49. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Do you mean Native Camera's camera output? If so, unfortunately not. The video is available only after user finishes recording the video. If you are talking about picking an image from Gallery with Native Gallery and displaying the image on an object, you can simply use
    object.GetComponent<Renderer>().material.mainTexture = NativeGallery.LoadImageAtPath(pickedImagePath);
     
  50. Sashimiii

    Sashimiii

    Joined:
    Sep 26, 2017
    Posts:
    15
    Hi Yasirkula,
    I might have not been clear enough, sorry for that! But I mean instead of opening the native camera, have the native camera on a certain game object so it shows in the Unity build instead of the native camera on phone. It's will then function like an "in-app camera" like Snapchat or Instagram. Is that possible?