This has actually been around for a while, but I just released version 2.2 and it occurred to me that I didn’t have a topic specifically for it. So here it is! UniFileBrowser is a runtime file-browser. It’s not a plugin, allows for lot of customization, and works on most platforms. Source code is included; it works with Unityscript and C# (and probably Boo though I haven’t tested that). Available on my site and the Unity asset store.
Feature highlights:
Can be skinned as desired, and the various GUI elements can be resized easily. Includes two demo GUISkins, as shown above.
Actions for opening and saving files, and opening folders.
Can filter files by extension, including multiple extensions. (e.g., if you want to list all .jpg and .png files.)
Can automatically add an extension when saving.
Can allow or disallow navigation to other folders.
Full keyboard control.
Can use multi-file selection, including shift for selecting a range of files and command/ctrl for adding/removing individual files.
Can have a delete button. (Destructive! Limiting to the initial folder is strongly recommended in this case.)
Can show volumes/hard drives.
When saving, can prevent input of “illegal” characters that are not allowed in file names in common file systems.
Can allow or disallow window dragging and resizing.
Includes detailed documentation.
There are a number of functions you can use, including:
OpenFileWindow: causes the file browser window to open, allowing the user to select a file. Uses a delegate so that a function you specify is called with the selected path. (Yes, delegates work with Unityscript.)
SaveFileWindow: as above, for saving files.
OpenFolderWindow: as above, for selecting folders.
CloseFileWindow: closes the file browser window.
SetPath: sets the path that the file browser window opens to by default.
SetWindowTitle: used for custom window titles.
FileWindowOpen: true or false depending on if the window is open.
GetFileWindowRect: returns the current rect for the window.
SendWindowCloseMessage: calls a function when the window is closed.
SendWindowChangeMessage: calls a function if the window is moved.
SetFileExtensions: sets the file filtering extensions at runtime.
Limitations:
No loading/saving game code is included. It’s a file-browser only. Loading and saving games is extremely game-dependent, so you’ll need your own code for that.
While it works on mobile, it’s currently limited to the built-in behavior for OnGUI code. So it’s functional but doesn’t have an ideal touch interface for scrolling and so on.
Since Unity doesn’t allow external file access in the web browser, it won’t work on that platform.
If you have any questions, find any bugs (never! ), or have any feature suggestions, post them here. If you bought from my site and don’t have the latest version (currently 2.6.1), send me a PM with the address you used when buying. Update notices are sent out automatically for new versions, but you need to make sure you opt in to that (if you don’t, then I can’t send any update notices to you), and you might also want to check your spam folder.
The point of UniFileBrowser is that it’s a file browser, it’s not a load/save system. It sends a string containing the file path to your functions (or an array of strings containing multiple file paths); what you do with that information totally depends on your game/app and what it does. Because of that, I can’t write any code that actually opens files for you, so you’ll need to write it yourself or find a third-party save system. You’ll have to ask the creators of PlayMaker about PlayMaker support.
I’m sorry to ask “dumb” question, but I am new to the computer world …
I want to open an excel file from my game … So if I understand correctly, your application just lets me browse to find my file … I need another application (such as “Easy save”, “save game” for example) that really opens my excel file. This is correct?
The link explains how to open an excel file in Unity … But I do not want to do that.
I just want to create a shortcut (a button) in my game that I opened the excel software. That way the player does not have to leave the game to go on his windows open excel file.
This is possible in your opinion?
UniFileBrowser works with playmaker. I have successfully configured it to load textures from a directory and then apply them to a game object. I may be able to dig up the FSM actions if you are still interested.
I’m sure it’s technically possible, but UniFileBrowser is heavily dependent on OnGUI code, so it would probably involve mostly rewriting it from scratch.
I want to use the OpenFolderWindow, so I can browser to a folder (Where the user will then save some stuff). But… I had thought you had implemented some “Create folder” functionality. Do I miss it somewhere? I know it is easy to implement (And I will), but if I misunderstand something, or it is indeed already made, I would want to save the time making it myself
I bought UnifileBrowser a while ago. Recently updated it.
OSX/WIN Standalone use in Unity 4:
Am trying to figure out how to use it to allow a user to import an image from their desktop or hard drive,
and have that image replace a texture that’s already live in runtime.
Basically, i’ve got a quasi 3d art gallery scene, and want the to user/player to be able to use it to see their own images in that gallery.
I’m not familiar with third-party save systems so I wouldn’t be able to recommend one. For importing images, you can use the WWW class with a file:// prefix, or Texture2D.LoadImage. Note that Unity only loads PNG and JPG formats; for others you’d have to write your own importer.
I bought EasySave2 and want to integrate UniFile with it to see if i can get a working solution.
I’ve brought both of them into my current 3d gallery project. No code conflicts.
Using OSX Unity 4 pro. Standalone. (Win standalone later.)
Have got UniFile’s example working in my 3d gallery.
Both the Open and Open Folder buttons work:
and display the name of the file i’ve chosen (the path to the file is not displayed),
or the name of the folder i’ve chosen. (the path to the folder is displayed.)
What i need next is to understand how i can access the path information to either a file or folder, which i can then use with EasySave2 to get my desired results.
The loading function you specify has the user-selected path passed to it as a string, so you can use the path with System.IO functions or whatever to do what you want with the file. I’m not familiar with EasySave2 or what its requirements are.
It would be better if you posted that in a new topic since it’s not related to UniFileBrowser, although from what I remember Application.dataPath is inside the app bundle.