gkngkc / UnityStandaloneFileBrowser

A native file browser for unity standalone platforms
MIT License
2.01k stars 317 forks source link

Open Folder Dialog Doesn't Work on WebGL #108

Open GavinR621 opened 2 years ago

GavinR621 commented 2 years ago

When attempting to open the folder dialog on WebGL, I get this error in my browser's JavaScript Console: MethodAccessException: Attempt to access method 'SFB.IStandaloneFileBrowser.OpenFolderPanelAsync' on type '' failed. Here's a screenshot: image

I'm using Unity 2020.3.10f1

Sven-vh commented 2 years ago

I'm having the same issue. Any solutions?

nerzid commented 1 year ago

I have this issue too. It is weird that this issue hasn't been fixed for a year. It looks like this unity asset cannot be used in WebGL due to this issue atm.

nerzid commented 1 year ago

I have this issue too. It is weird that this issue hasn't been fixed for a year. It looks like this unity asset cannot be used in WebGL due to this issue atm.

It turns out this is not an issue with the asset but the "Example Usage" on the main page. Basically, you can't expect the File Browser to work on WebGL without using WWW for security sandbox reasons of unity. You also should use OnPointerDown interface and attach the script to the button that you want to open the file browser with instead of using onClick function of Button in inspector. Then it works!

There is already an example script for this here

Hope this helps someone.