Search Unity

Native File Picker for Android & iOS [Open Source]

Discussion in 'Assets and Asset Store' started by yasirkula, Jun 15, 2020.

  1. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    lol another nice use of chatgpt. I can't help with this issue due to my inexperience but thank you for sharing your findings.
     
  2. AdrienIsHere

    AdrienIsHere

    Joined:
    Feb 28, 2020
    Posts:
    4
    @yasirkula I am using your file picker, and I have a strange issue on Android, I'm trying to get an image from my gallery, but I get a prompt that says "No apps can perform this action.", my default gallery app is Google Photos, I was unable to find any solution so far, but I'm going to assume the file picker doesn't recognize Google photos as a file manager? Any solutions?
     
  3. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  4. AdrienIsHere

    AdrienIsHere

    Joined:
    Feb 28, 2020
    Posts:
    4
    Sure thing :

    Code (CSharp):
    1.  
    2.  public void OpenFileBrowser()
    3.     {
    4.         string fileType = NativeFilePicker.ConvertExtensionToFileType("png,jpg,jpeg");
    5.         NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
    6.         {
    7.             if (path == null)
    8.             {
    9.                 Debug.Log("action was cancelled");
    10.             }
    11.             else
    12.             {
    13.                 finalPath = path;
    14.                 byte[] imageBytes = File.ReadAllBytes(finalPath);
    15.                 string stringArray = ConvertFromBytesToString(imageBytes);
    16.                 SaveModelAngleView.modelsList.imageReferenceBytes = stringArray;
    17.                 SaveModelAngleView.SaveModelList(ModelSettings.instance.model.name);
    18.             }
    19.         }, new string[] { fileType });
    20.     }
    21.  
    I also Added the following permissions in the AndroidManifest.xml, just in case READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE and MANAGE_EXTERNAL_STORAGE, in case my app was trying to access Google Files instead, but to no avail.
     
    Last edited: Feb 16, 2023
  5. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You can only pass a single extension to ConvertExtensionToFileType. Try replacing
    new string[] { fileType }
    with this:
    NativeFilePicker.ConvertExtensionToFileType("png"), NativeFilePicker.ConvertExtensionToFileType("jpeg")


    Note that for media picking, I'd recommend using NativeGallery instead. Its LoadImageAtPath function may also be used to load images other than png and jpg on Android & iOS (user can pick any image file from their Gallery freely).
     
  6. AdrienIsHere

    AdrienIsHere

    Joined:
    Feb 28, 2020
    Posts:
    4
    Hey man, sorry for the late response, it worked, thanks a lot! I am going to stick with the file picker, I want my user to be able to import fbx models as well, thanks a lot!
     
    yasirkula likes this.
  7. noam_baba

    noam_baba

    Joined:
    Mar 14, 2023
    Posts:
    8
    Hi, from some reason on IOS there is only acesses to files and no images, this is my script:
    Code (CSharp):
    1. try{
    2.   // Use UTIs on iOS
    3.    string[] fileTypes = new string[] { "public.image", "public.movie" };
    4. var permission = NativeFilePicker.PickFile(path =>
    5.     {
    6.         if (string.IsNullOrEmpty(path))
    7.         {
    8.             log.logMsg(LogType.Log, $"{nameof(InboxPopup)}: AddAttachmentImageFile(), Did Not Fetch File");
    9.         }
    10.         else
    11.         {
    12.             log.logMsg(LogType.Log, $"{nameof(InboxPopup)}: AddAttachmentImageFile(), Success !, File Path: {path}");
    13.             _currentSelectedFileInfo = new FileInfo(path);
    14.             log.logMsg(LogType.Log, $"File Size: {_currentSelectedFileInfo.Length}");
    15.  
    16.             _currentSelectedFileAttachmentPath = path;
    17.             _fileAttachmentObject.SetActive(true);
    18.             _fileAttachmentNameText.text = _currentSelectedFileInfo.Name;
    19.             var fileSizeInMB = _currentSelectedFileInfo.Length / 1000000f;
    20.  
    21.             _fileAttachmentSizeText.text = IsCurrentSelectedFileSizeOk()
    22.                 ? string.Format(FILE_ATTACHMENT_SIZE_TEXT, fileSizeInMB, string.Empty)
    23.                 : string.Format(FILE_ATTACHMENT_SIZE_TEXT, fileSizeInMB, EXCEEDS_MAX_SIZE_TEXT);
    24.         }
    25.     }, fileTypes);
    26. }
    27. catch (Exception Ex)
    28. {
    29.     log.logMsg(LogType.Error, $"{nameof(InboxPopup)}: AddAttachmentImageFile(), An Exception Was Thrown, Ex: {Ex}");
    30. }
     
  8. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Hi, Photos app may not show up while using this plugin you're right. For media access, consider using my other plugin Native Gallery.
     
  9. noam_baba

    noam_baba

    Joined:
    Mar 14, 2023
    Posts:
    8
    Its work grate on IOS but for some reason it's don't work on other android device then android 13, Its look that there is no permission request, do you know why it is happen?(it's mean the issue happen on android 12 and lower)
     
  10. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I'm assuming RequestPermission returns Denied without showing a dialog. You can analyze the AndroidManifest in the resulting APK file (this can be done via Android Studio for example) and see if the READ_EXTERNAL_STORAGE permission is there, without any maxSdk attribute. You can also see if the issue can be reproduced on an empty Unity project.
     
  11. noam_baba

    noam_baba

    Joined:
    Mar 14, 2023
    Posts:
    8
    Thank you for the fast answer,
    I have this attribute on my manifest:

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove" />
    while this is my manifest attribute:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.bws" android:versionCode="1" android:versionName="1.0">
     
  12. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    NativeFilePicker asks that READ_EXTERNAL_STORAGE permission so I'd recommend removing that line from your manifest.
     
  13. falconhe

    falconhe

    Joined:
    Nov 15, 2018
    Posts:
    1
    Hi, yasirkula. I am using this plugin on Android, just try to pick an image file. It works well on my PC but when I built it on Android, it pops up a panel to show that "no apps can perform this action". I've already add read/write permission in manifest. Does anybody know this issue?

    this is my manifest


    and this is my implementation, it works on windows but not on android.
    upload_2023-4-15_20-1-51.png
     
  14. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Looking at Discord, I'm assuming this issue is resolved. For future readers: "image/*" should be passed directly to PickFile function without going through ConvertExtensionToFileType because it's not an extension, it's an Android MIME type.
     
  15. DCK2022

    DCK2022

    Joined:
    Dec 25, 2022
    Posts:
    4
    Hi, yasirkula,
    I found out if just a * is used in the ConvertExtensionToFileType all files are greyed out.
    No I set it to csv which is my filetype I want to load.
    Seems this also works on MacOS.
    However, on my Android device with Android11 I can see the files in my download folder. But they are still greyed out and can not be clicked. Permission request was confirmed.
    Any idea what to do?
     
  16. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    ConvertExtensionToFileType expects an extension. To pick any files, you can pass the following values directly to PickFile (without going through ConvertExtensionToFileType), depending on the OS:

    Android:
    "*/*"

    iOS:
    "public.item", "public.content"


    Code (CSharp):
    1. string[] allowedFileTypes;
    2. if( Application.platform == RuntimePlatform.Android )
    3.     allowedFileTypes = new string[] { "*/*" };
    4. else
    5.     allowedFileTypes = new string[] { "public.item", "public.content" };
    6.  
    7. NativeFilePicker.PickFile( callback, allowedFileTypes );
     
    Last edited: Nov 19, 2023
    RyuuyaS likes this.
  17. DCK2022

    DCK2022

    Joined:
    Dec 25, 2022
    Posts:
    4
    Thank you so much for the quick reply.
    Indeed it works fine passing "*/*" instead of using the ConvertExtensionToFileType method.
     
    yasirkula likes this.
  18. BeardedChris

    BeardedChris

    Joined:
    Aug 23, 2021
    Posts:
    8
    ist it possible to add an icon to my custom file extension?
     
  19. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    From Xcode, yes it seems possible with Small icon and Large icon slots. Unfortunately this isn't implemented in my automated method in Unity.

     
  20. waydigitalsolutions

    waydigitalsolutions

    Joined:
    Dec 2, 2016
    Posts:
    7
    Hey! Great asset!
    short question: is custom file support at all planned for android? It's a big shame that it only seems to work for ios...
     
  21. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Hi! I'm unfortunately unaware of a way to achieve this on Android.
     
  22. unity_2451C087C01993D824AB

    unity_2451C087C01993D824AB

    Joined:
    Oct 8, 2022
    Posts:
    10
    @yasirkula hello, thank you for your amazing work

    I am trying to get the path of the .obj file in IOS
    Code (CSharp):
    1. public void LoadObj()
    2.     {
    3.         if(isCheck == false)
    4.         {
    5.             string FileType = NativeFilePicker.ConvertExtensionToFileType("obj");
    6.  
    7.             NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
    8.             {
    9.                 if (path == null)
    10.                 {
    11.                     Debug.Log("Canceled");
    12.                 }
    13.                 else
    14.                 {
    15.                     object = new OBJLoader().Load(path);
    16.                     Debug.Log("Picked file : " + path);
    17.              
    18.                 }
    19.             }, new string[] {FileType});
    20.         }
    21.      
    22.     }
    when I check on Mac (editor) it works fine
    But, after build it provide me the path but when I try to load it,
    it says ArgumentNullException: Value cannot be null

    I checked github issue page and README and tried it. But it didn't work.
    I was wondering if I did something wrong with the setting or there is something wrong with my code


    Log
    /private/var/mobile/Containers/Data/Application/E7E0ADA9-D2EB-4276-B4AC-0B8F281F5F1E/tmp/com.DefaultttCompany.tutotest-Inbox/Pin.obj objImportbtn:ClickStart() UnityEngine.EventSystems.StandaloneInputModule:process()

    ArgumentNullException: Value cannot be null. Parameter name: shader Dummiesman.OBJLoaderHelper.CreateNullMaterial () (at <00000000000000000000000000000000>:0) Dummiesman.OBJObjectBuilder.Build () (at <00000000000000000000000000000000>:0) Dummiesman.OBJLoader.Load (System.IO.Stream input) (at <00000000000000000000000000000000>:0) Dummiesman.OBJLoader.Load (System.String path, System.String mtlPath) (at <00000000000000000000000000000000>:0) objImportbtn.ClickStart () (at <00000000000000000000000000000000>:0) UnityEngine.Events.UnityEvent.Invoke () (at <00000000000000000000000000000000>:0) UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at <00000000000000000000000000000000>:0) UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, System.Boolean pressed, System.Boolean released) (at <00000000000000000000000000000000>:0) UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () (at <00000000000000000000000000000000>:0) UnityEngine.EventSystems.StandaloneInputModule.Process () (at <00000000000000000000000000000000>:0) UnityEngine.EventSystems.StandaloneInputModule:process()
     
    Last edited: Jun 6, 2023
  23. unity_2451C087C01993D824AB

    unity_2451C087C01993D824AB

    Joined:
    Oct 8, 2022
    Posts:
    10

    And I am not sure how to add obj to "Window-NativeFilePicker Custom Types"
     
  24. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @unity_2451C087C01993D824AB Hi! This error comes from OBJLoader plugin, maybe it doesn't support iOS? Since you can already pick obj files on iOS, you don't seem to make any changes to NativeFilePicker Custom Types.

    PS. Also try adding a Cube to your scene if it's empty. Maybe the default shaders are stripped and that causes issues.
     
  25. waydigitalsolutions

    waydigitalsolutions

    Joined:
    Dec 2, 2016
    Posts:
    7
    The strange thing is: on my Pixel 5, I can go directly into the folder and when using "*/*" as a filetype I can see my file, and can work without a problem with the path I am getting back from your code.
    So at least on this phone it seems to work?
    The only thing that doesn't work at all, is if I am trying to go through 3rd party file browsers.
    I know the Pixel 5 is not really new, but I think it still has the latest android os?
     
  26. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    "*/*" means all file types so it can work yeah. You'll need to verify the file extension in your callback function and you should be good to go.
     
  27. kubsasha1992

    kubsasha1992

    Joined:
    Dec 3, 2019
    Posts:
    3
    hello, I want to thank you in advance for your work, I ran into a problem loading glb files
    Code (CSharp):
    1. string fileType = NativeFilePicker.ConvertExtensionToFileType("*.glb");//NativeFilePicker.ConvertExtensionToFileType("glb");
    2. NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
    3. {
    4.     var url = "file://" + path;
    5.     var www = new WWW(url);
    6.     byte[] bytes = System.IO.File.ReadAllBytes(path);
    7.     nftInfo.file2d_md5 = null;
    8.     objBtn2D.SetFile(bytes);
    9. }, new string[] {fileType});
    in my phone open window
    "action is not supported by any application" and cancel button unity version 2021.3.24f1
     
  28. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I think glb isn't recognized by Android as a known file type. You can set fileType to "*/*" and inside PickFile's callback, verify that the picked file is indeed a glb.
     
  29. kubsasha1992

    kubsasha1992

    Joined:
    Dec 3, 2019
    Posts:
    3
    I import in my project NativeGallery and NativeFilePicker, I have both plugins in my project (NativeGallery and NativeFilePicker) NativeGallery works but NativeFilePicker doesn't work, I use
    NativeFilePicker.ConvertExtensionToFileType("obj");
    NativeFilePicker.ConvertExtensionToFileType("*/*");
    NativeFilePicker.ConvertExtensionToFileType("*");
    NativeFilePicker.ConvertExtensionToFileType("gif");
    NativeFilePicker dont work in my project
     
  30. kubsasha1992

    kubsasha1992

    Joined:
    Dec 3, 2019
    Posts:
    3
    Code (CSharp):
    1.             NativeFilePicker.PickFile((path) =>
    2.             {
    3.                 var url = "file://" + path;
    4.                 var www = new WWW(url);
    5.                 byte[] bytes = System.IO.File.ReadAllBytes(path);
    6.                 nftInfo.file3d_md5 = null;
    7.                 objBtn3D.SetFile(bytes);
    8. #if UNITY_ANDROID
    9.             }, new string[] {"*/*"});
    10. #elif UNITY_IOS
    11.             }, new string[] {"public.item", "public.content"});
    12. #endif
    WORKING ^.^
    My problem is "NativeFilePicker.ConvertExtensionToFileType() " callback >> empty
     
    Last edited: Jun 6, 2023
    yasirkula likes this.
  31. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    ConvertExtensionToFileType only accepts an extension, so "*" won't work in there. However, if the extension isn't recognized by the OS, it will return an empty/null string. I'd expect gif to be recognized but obj may not be recognized.
     
  32. Ramzan_16

    Ramzan_16

    Joined:
    Mar 22, 2023
    Posts:
    2
    I have the error "This action is not supported in more than one application" Here is the code;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using System.IO;
    using NativeFilePickerNamespace;

    public class PlayerChangeMusic : MonoBehaviour
    {
    public static string FilePath;
    public static int PlayerChangeInt = 0;

    private void Awake() {
    FilePath = PlayerPrefs.GetString("FilePathSaved");
    PlayerChangeInt = PlayerPrefs.GetInt("ChangeSaved");
    }
    private void Start() {

    }
    public void OpenExplorer()
    {

    // Don't attempt to import/export files if the file picker is already open



    string FileType = NativeFilePicker.ConvertExtensionToFileType("mp3,wav");


    // Pick a PDF file
    NativeFilePicker.Permission permission = NativeFilePicker.PickFile( ( path ) =>
    {
    if( path == null )
    Debug.Log( "Operation cancelled" );
    else
    FilePath = path;
    }, new string[] { FileType } );

    PlayerPrefs.SetString("FilePathSaved", FilePath);

    }
    public void MyMusic()
    {
    PlayerChangeInt = 1;
    PlayerPrefs.SetInt("ChangeSaved", PlayerChangeInt);
    PlayerPrefs.Save();
    }

    public void GameMusic()
    {
    PlayerChangeInt = 0;
    PlayerPrefs.SetInt("ChangeSaved", PlayerChangeInt);
    PlayerPrefs.Save();
    }
    public void OpenExplorer2()
    {
    #if UNITY_ANDROID && UNITY_EDITOR
    // Use MIMEs on Android
    string[] fileTypes = new string[] { "*" };
    #else
    // Use UTIs on iOS
    string[] fileTypes = new string[] { "public.image", "public.movie" };
    #endif

    // Pick image(s) and/or video(s)
    NativeFilePicker.Permission permission = NativeFilePicker.PickMultipleFiles( ( paths ) =>
    {
    if( paths == null )
    Debug.Log( "Operation cancelled" );
    else
    {
    for( int i = 0; i < 1; i++ )
    {
    //File.Open;
    //FileShare.Inheritable;
    FilePath = paths;
    }
    }
    }, fileTypes );

    }
    }
     
  33. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @Ramzan_16 You can't pass multiple extensions to ConvertExtensionToFileType. You should pass them one by one, one function call per extension.
     
  34. Ramzan_16

    Ramzan_16

    Joined:
    Mar 22, 2023
    Posts:
    2
    Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much Thank you very much :):):):):):):):):):):):):)
     
    yasirkula likes this.
  35. ekta_augview

    ekta_augview

    Joined:
    Jun 18, 2023
    Posts:
    3
    Hello Yasir, I am having the same issue while implementing file export. No error in logcat. Here I am attaching logcat for your reference. Please help me out!
    Many thanks.
    upload_2023-7-10_16-29-41.png
     
  36. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @ekta_augview Looking at the source code, this code must be returning true since there are no exceptions in logcat. Then this value is passed on to managed code as-is. I unfortunately can't spot the problematic line in the source code. I'd recommend checking out logcat for exception messages that have tag Unity and start with label "Exception:".
     
  37. ekta_augview

    ekta_augview

    Joined:
    Jun 18, 2023
    Posts:
    3
    Hello Yasir, Thanks for pointing out. I found following exception. Can you please suggest a solution for that as my path is correct but, still doesn't creating file on that location.

    upload_2023-7-11_10-51-9.png
     
  38. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Discussion continued via e-mail.
     
  39. DhiaSendi

    DhiaSendi

    Joined:
    May 16, 2018
    Posts:
    43
    Hi Yasir,
    Thank you very much for the great asset,
    I'm getting a weird bug where I got the native file browser and choose a specific file but the callback only execute after clicking on the power button on Oculus Quest 2 wait a second then awake it (in other word putting it on sleep then awake it)

    Code (CSharp):
    1.     void Start()
    2.     {
    3.         NativeFilePick();
    4.     }
    5.     private void NativeFilePick()
    6.     {
    7.         //string[] fileTypes = new string[] { "audio/*" };
    8.         string fileTypes =  "audio/*";
    9.  
    10.         NativeFilePicker.Permission permission = NativeFilePicker.PickFile((paths) =>
    11.         {
    12.             if (paths == null)
    13.                 Debug.Log("Operation cancelled");
    14.             else
    15.             {
    16.                 print(paths.Substring(0,paths.LastIndexOf("/")));
    17.  
    18.                 FilePath = paths.Substring(0, paths.LastIndexOf("/"));
    19.  
    20.                 dir = new DirectoryInfo(FilePath);
    21.                 info = dir.GetFiles("*.*");
    22.                 CountFilesInDir();
    23.  
    24.             }
    25.         }, fileTypes);
    26.  
    27.         Debug.Log("Permission result: " + permission);
    28.  
    29.  
    30.     }
    31.  
    32.  
     
  40. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    @DhiaSendi Sorry for the late response, had some very busy weeks. I'll send you an experimental version of the plugin when I get the chance. PS. Discussion continued on Discord.
     
    Last edited: Aug 17, 2023
  41. birdupcompany

    birdupcompany

    Joined:
    Aug 24, 2023
    Posts:
    2
    I will say in advance that my problem is not related but native file picker.
    If I use Mono (scripting backed), the ads (Unity ads) work like clockwork, but as soon as I switch to IL2CPP, the ads don't work well. Help me please.
     
  42. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  43. kesdesng

    kesdesng

    Joined:
    Sep 3, 2017
    Posts:
    6
    I am having an issue on android platform , when I try to browse files I get a message like "No apps can perform this action" I'm using the latest version updated from the asset store. What is the issue any idea? suggestion ?
     
  44. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    May I see your NativeFilePicker.PickFile code?
     
  45. kesdesng

    kesdesng

    Joined:
    Sep 3, 2017
    Posts:
    6
    Sure here it is
    Code (CSharp):
    1.     private void AndroidBrowseFile()
    2.     {
    3.         string fileType = NativeFilePicker.ConvertExtensionToFileType("*");
    4.         NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
    5.         {
    6.             if (path == null)
    7.             {
    8.                 Debug.Log("Operation cancelled");
    9.             }
    10.             else
    11.             {
    12.                 Debug.Log("Picked file: " + path);
    13.             }
    14.             SetFileInfo(path);
    15.  
    16.         }, fileType);
    17.         Debug.Log("Permission result: " + permission);
    18.     }
     
  46. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  47. kesdesng

    kesdesng

    Joined:
    Sep 3, 2017
    Posts:
    6
    yasirkula likes this.
  48. tom41_10tt

    tom41_10tt

    Joined:
    Oct 7, 2021
    Posts:
    9
    Hello, I tried to build my project with your plugin to Android but i got these errors:

    -The type or namespace name 'SettingsProvider' could not be found

    -The type or namespace name 'SettingsProviderAttribute' could not be found

    - The type or namespace name 'SettingsProvider' could not be found

    -The type or namespace name 'MenuItemAttribute' could not be found

    - type or namespace name 'MenuItem' could not be found

    Can somebody hekp me with that?
     
  49. kennethcerrado23

    kennethcerrado23

    Joined:
    Oct 21, 2023
    Posts:
    8
    hello, im having a problem. when i run my app in a simulator in the unity, everything works fine but when i run it on my android phone, i can't select a file. it just shows files but i can't select it.
    here's my code:

    public void LoadFile()
    {
    string[] mimeTypes = new string[] { "model/obj", "model/mtl" };
    NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
    {
    if (path == null)
    Debug.Log("Operation cancelled");
    else
    {
    string mimeType = GetFileMimeType(path);
    FinalPath = path;
    Debug.Log("Picked file: " + FinalPath + " with MIME type: " + mimeType);
    if (mimeType.Equals("model/obj", System.StringComparison.OrdinalIgnoreCase))
    {
    LoadAndDisplayObjFile(FinalPath);
    }
    else if (mimeType.Equals("model/mtl", System.StringComparison.OrdinalIgnoreCase))
    {
    LoadAndApplyMtlFile(FinalPath);
    }
    }
    }, mimeTypes);
    }
     
    Last edited: Oct 24, 2023
  50. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879