Native File Picker for Android & iOS [Open Source]

If you are supporting only Android, then you can use NativeGallery.GetAudioFromGallery. Otherwise, you can modify the example code so that it picks mp3 files instead of pdf files.

hello, i cannot, for the life of me, where the AUTO_SETUP_FRAMEWORKS and AUTO_SETUP_ICLOUD are. i’ve been trying to solve the iOS building issue for days, and i even tried doing the manual set up but to no avail.

They are in this file in your project: UnityNativeFilePicker/Plugins/NativeFilePicker/Editor/NativeFilePickerPostProcessBuild.cs at 77051c25bd52056d095c5909fa8af678400474bc · yasirkula/UnityNativeFilePicker · GitHub

hello @yasirkula i have a question. The plugin can open a pdf file on IOS?
because I can see the file, but when I select it nothing happens, the selection window closes and I do not receive any error in the console

heres my code

string pdfType = NativeFilePicker.ConvertExtensionToFileType("pdf");

#if UNITY_IOS && !UNITY_EDITOR
      
            NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) => { if( path == null )
                    Debug.Log( "Operation cancelled" );
                else
                    Debug.Log( "Picked file: " + path ); }, new string[] { pdfType});
          
#endif

NativeFilePicker doesn’t have this functionality, it can only pick files. Processing/opening these files must be handled in your script. Currently, Debug.Log( "Picked file: " + path ); is executed when a PDF file is picked. You need to add your PDF opening logic there.

Hello.
I have a question.

Is it possible to determine that a file is being read when a file is selected?
When I select a large file, such as a video file, I don’t know if it’s loading.

I want to display the loading.

Until the callback function is called (or permission returns Denied), you can assume that the file is loading. You just need to make sure that NativeFilePicker.IsFilePickerBusy() returns false before calling NativeFilePicker.PickFile.

Hello.
I have a question.

When I select a video file stored in a USB memory, it waits for about 10 seconds.
Is it possible to close the browser immediately after selecting it?

I don’t know if I can select it because I have been waiting for a long time.

Video file is being copied to local storage during that time. Closing the browser immediately will require modification to the native source code. I unfortunately can’t focus on this for the time being.

Is it possible to determine whether copying to local storage is in progress?

At its current state, screen will freeze as you’ve experienced while copy is in progress.

Hey, i’m trying to get a user to pick a directory as I’ll require access to multiple images (more than a user would have the patience to select).
I have tried just getting the user to select one image and use that as a filepath and get the directory information that way but I couldn’t actually access the other files. My functionality works when all the files are selected using multiplefiles, just not single.
Is there a way for the user to pick just a directory folder instead? I’ve tried using different mime types but it didn’t work out.

It isn’t possible with NativeFilePicker but SimpleFileBrowser might help: GitHub - yasirkula/UnitySimpleFileBrowser: A uGUI based runtime file browser for Unity 3D (draggable and resizable)

I want to be able to pick jpg and png images on Androd for now. Consequently I use

    private static readonly string[] allowedFileTypes = new string[] {
        "image/jpg",
        "image/png",
    };

In Player Settings Write Permission is set to “External” - however, I just want to import.
On Android In the picker all Images are greyed out, I cannot select anything.

What could be the problem?

Can you try changing “image/jpg” to “image/jpeg”?

Thanks, I simply changed it to “image/*”, that solved it.

1 Like

Hey :slight_smile:

We have some issues with the plugin when we use the Unity cloud build service. This results in that the files (e.g fbx, obj) no longer having their original file names but having a “.bin” appended to them.
This only occurs on Android using IL2CPP build in the Unity cloud. A local build works as expected. Are there perhaps settings we are missing?

The issue is that the FBX assets in your Unity project become BIN files for some reason, right? Or is it that the FBX files you pick with this plugin are returned as BIN files?

These are the paths/files we receive from the FilePicker as callback. These are different under the circumstances described above. The resulting files are also correct and complete. Only the filename/path has the extension .bin

Example: /path/to/file/example.fbx.bin
Expected result: /path/to/file/example.fbx

This happens only with “no classic media types”. Pictures, videos, etc. work as expected.
It also seems to be independent of the Unity version used. We are using 2020.3.17.

This is not a big issue for us. It just an unexpected behavior.

Thanks for your help :slight_smile:

I think this line returns .bin instead of .fbx for FBX files when Cloud Build is used. Thanks for reporting it. I’d like to keep it as is if it doesn’t affect your app’s functionality.