How do I let the user select a local file for my application to use?

I can utilize a jpeg from a source file on drive using wwwtexture, but how do I allow Unity to allow user to browse for a file on their hard drive. Just like they would from a typical app.

Thx for the help!

P

There is no built in file browser for the player, so you would need to roll your own using the .net frameworks classes for file system access. A while ago I wrote a UnityGUI one - it could probably use a lot of love, but it is a good starting point.

This of-course only works for stand-alones - not webplayers (security restricts access to the users file system). If you need to allow the user to upload files to your webplayer, you should go through HTML forms for that.

I've done that before and a good trick is to have your webplayer run in a frameset with a zero pixel tall data frame which you would use to communicate with the upload process. You can use Application.ExternalEval to add your upload form to the surrounding HTML.

The trick is then to have this form target the dataframe with your receiving server-side script - overseeing the file upload operation. Once the upload is completed, your server-side script (now outputting to the hidden dataframe) should output javascript to hide the HTML form and send the URL of the uploaded file to the webplayer.

In the editor, you can use EditorUtility.OpenFilePanel to show an window in which the user can select a file, and the path of the selected file is returned. You can then use that load the file or do whatever you want with it. I don't know of anything similar you can use in your actual application, but you could use a simple text field in which the user enters the name of the file they want to load. Creating a full-blown file-select dialog where the user can browser their hard-drive and external devices would be more difficult.

I’m working with UniFileBrowser. you wil get it in the Asset Store or directly from starscene
It’s easy to integrate and works perfectly for standalones.

if you want to change the layout, you have to invest a little time but it works.

There’s also File Browser & Save/Load UI from the Asset Store:

http://u3d.as/content/pigasus-games/file-browser-save-load-ui/3rU

This asset in the unity store is what you’re looking for. You can have them pick files from their computer

https://assetstore.unity.com/packages/tools/gui/runtime-file-browser-113006,This asset in the unity store is what you are looking for.