UnityNativeFilePicker icon indicating copy to clipboard operation
UnityNativeFilePicker copied to clipboard

Not able to pick .GLB file type in iOS

Open nextechar-hardik opened this issue 1 year ago • 6 comments

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

nextechar-hardik avatar Jun 08 '23 18:06 nextechar-hardik

Can I see your code?

yasirkula avatar Jun 08 '23 20:06 yasirkula

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

nextechar-hardik avatar Jun 14 '23 09:06 nextechar-hardik

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

yasirkula avatar Jun 14 '23 09:06 yasirkula

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

VincentMarnier avatar Jun 18 '24 12:06 VincentMarnier

Previous post

It seems a deprecated method is used to acquire UTType: https://github.com/yasirkula/UnityNativeFilePicker/blob/da3f797fd86ca715236632d8d8f0d8ae3d8f4578/Plugins/NativeFilePicker/iOS/NativeFilePicker.mm#L100 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.

VincentMarnier avatar Jun 18 '24 13:06 VincentMarnier

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.

yasirkula avatar Jun 18 '24 15:06 yasirkula