Skip to content

Not able to pick .GLB file type in iOS  #41

Open

Description

@nextechar-hardik

Description of the bug

Not able to select .glb file from storage in iOS devices.

Reproduction steps

Use file picker code with following condition
if (fileExtension == ".glb" || fileExtension == ".gltf" || fileExtension == ".obj")

its working fine in Editor / Android but not working in iOS , not able to select .glb file.

Platform specs

  • Unity version: Any
  • Platform: iOS
  • Any iOS version
  • How did you download the plugin: Github

Activity

  1. yasirkula commented on Jun 8, 2023

    @yasirkula
    Owner

    Can I see your code?

  2. nextechar-hardik commented on Jun 14, 2023

    @nextechar-hardik
    Author

    Okay let me create demo project and will share that here.

  3. yasirkula commented on Jun 14, 2023

    @yasirkula
    Owner

    I only need to see your usage of PickFile function. You can copy your C# code here.

  4. VincentMarnier commented on Jun 18, 2024

    @VincentMarnier

    Hello.

    First of all, thanks for the hard work and the code quality. I have dug a bit to understand what UnityNativeFilePicker was doing exactly and it is very clear.

    I am having the same issue so I am updating this post as I assume @nextechar-hardik wont.

    I have an abstraction layer on top of UnityNativeFilePicker so I can use different methods to pick files (or pick files on other systems), so I won't give the full code as it is not related, but it ends up calling the following:

    string[] extensions = new [] {
        NativeFilePicker.ConvertExtensionToFileType("png"),
        NativeFilePicker.ConvertExtensionToFileType("jpg"),
        NativeFilePicker.ConvertExtensionToFileType("jpeg"),
        NativeFilePicker.ConvertExtensionToFileType("gltf"),
        NativeFilePicker.ConvertExtensionToFileType("glb")
    }
    NativeFilePicker.PickFile(path => Debug.Log(path), extensions);
    

    Only png, & jpeg files can be picked. GLTF & GLB are not displayed.

    I found the following post that might be useful:
    https://developer.apple.com/forums/thread/716575

  5. VincentMarnier commented on Jun 18, 2024

    @VincentMarnier
    Previous post

    It seems a deprecated method is used to acquire UTType:

    CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag( kUTTagClassFilenameExtension, (__bridge CFStringRef) extension, NULL );

    The initializer is now the correct way to do this:
    https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/init(tag:tagclass:conformingto:)

    I made a test in xcode, without deploying to anything. Using a basic Swift project:
    Capture d’écran 2024-06-18 à 15 02 27

    Using the new initializer seems to fix the issue.

    Nevermind, it works with the deprecated method too. My code was just garbage.
    I'll try to find another answer to why it fails then.

  6. yasirkula commented on Jun 18, 2024

    @yasirkula
    Owner

    GLB and GLTF don't exist in the filetype lists I've posted: https://github.com/yasirkula/UnityNativeFilePicker?tab=readme-ov-file#a-importing-files. The only possible solution is to allow picking all files and then check the returned files' extensions in the callback function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions