Search Unity

UniFileBrowser - runtime file browsing

Discussion in 'Assets and Asset Store' started by Eric5h5, May 4, 2013.

  1. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Did you change some of the settings? This is what I get:

    Screen Shot 2015-05-19 at 8.26.46 PM.png

    --Eric
     
  3. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    Well I didn't but I deleted the example.unity file and re imported it, and now it works thanks!
     
  4. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    Hey Eric, would it be possible to get a callback when the cancel button is clicked? When opening the browser, I enable a 4.6 UI Image background to prevent clicks from falling through to my canvas. I disable this when a file is picked, but I also want to disable it when the cancel button is pressed.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Can you use SendWindowCloseMessage?

    --Eric
     
  6. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    Absolutely. Sorry, didn't notice it in there.
     
  7. Dago1

    Dago1

    Joined:
    Jan 8, 2015
    Posts:
    4
    Hi,

    after importing your Filebrowser into my project I got this error.

    Assets/FileBrowser/Scripts/FileBrowser.cs(424,45): error CS0117: `System.IO.Directory' does not contain a definition for `GetLogicalDrives'

    Do you have any idea?

    Greetings & Thanks!
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You're probably in the wrong topic, since my asset doesn't have any "Assets/FileBrowser/Scripts/FileBrowser.cs" file.

    --Eric
     
  9. Eric-Pratt

    Eric-Pratt

    Joined:
    Apr 28, 2014
    Posts:
    30
    I'm trying to get the dcim folder in iOS, what would I set setpath to to get it?
    I've tried: private/var/mobile/Media/DCIM/ and couple other combinations but all I get is error.
    thanks,
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm not sure; you'd be better off starting a topic about that in the iOS section.

    --Eric
     
  11. Eric-Pratt

    Eric-Pratt

    Joined:
    Apr 28, 2014
    Posts:
    30
    well, what's an example path that works?
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm sorry but I can't help with platform-specific path questions. UniFileBrowser can access any valid path, but it has no special powers to bypass Unity and/or platform limitations in that area. Please start a topic in the iOS section, and I'm sure someone will be able to answer.

    --Eric
     
  13. Dago1

    Dago1

    Joined:
    Jan 8, 2015
    Posts:
    4
    Hey,

    after buying your product and arranging it in my project, I get the same error somebody mentioned before. It starts with "Error...Acccess to the path..." not allowed. After using GUI.matrix to rescale all the Gui stuff, the Error box is elsewhere, but definitly not in the middle anymore. Where are the parameters to adjust it?

    Thanks a lot!
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    There currently aren't any parameters for adjusting the error box...it's intended to appear in the middle of the screen, so it would seem using GUI.matrix interferes with that.

    --Eric
     
  15. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    471
    Hello Eric,
    nice plugin... will there be a uGUI solution too?
    I don't use and like old Unity GUI.
    thx
    M.
     
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Maybe, but I don't have any current plans. OnGUI isn't going anywhere.

    --Eric
     
  17. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    471
    thx for fast reply.
    hmm sry to hear no uGUI...
    ok then i have to look further...
    don't know why people still use this bloated OnGui stuff...
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's not bloated, just different. It's quite suitable for creating stuff programmatically, which is what UFB does. uGUI is good for laying things out manually in the editor.

    --Eric
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Just got word that the annoying "GUI.SetNextControlName" error will be fixed in Unity 5.2. Better late than never!

    --Eric
     
  20. DCrosby

    DCrosby

    Joined:
    Jan 13, 2013
    Posts:
    86
    I am shocked nobody has asked for this, but how about a "Back" button, where you can browse to a different path, inc case you made a mistake, go back up a folder ??
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I think the reason why nobody asked is that you can just select the path drop-down at the top, then you can go back a level (or more than one level).

    Screen Shot 2015-08-24 at 7.43.54 PM.png

    I think it would be more useful to add the option of forward/back buttons, like standard OS X file dialogs have, which are like forward/back buttons in a web browser.

    --Eric
     
  22. DCrosby

    DCrosby

    Joined:
    Jan 13, 2013
    Posts:
    86
    I think it would be more useful to add the option of forward/back buttons, like standard OS X file dialogs have, which are like forward/back buttons in a web browser.

    --Eric[/QUOTE]


    So is that a feature acknowledgement ? For a future update ? :D
     
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
  24. Lopiken

    Lopiken

    Joined:
    Jan 15, 2014
    Posts:
    4
    I've encountered a very strange issue. When running from the editor, everything works fine. However, when running from a Mac or Windows build, the OpenFileWindow method opens the file selector, but none of the folders or files do anything when selected. You can double-click them, or select them and select Open, and nothing happens. But then it works fine if I call SaveFileWindow first and close that file selector, then call OpenFileWindow. It's like some initializing code isn't being set in the OpenFileWindow method.

    Here's my code:
    Load:
    string[] extensions = {"smsf"};
    UniFileBrowser.use.SetFileExtensions(extensions);
    UniFileBrowser.use.OpenFileWindow((string aFilepath) => {
    Debug.LogError("Open?");
    });
    UniFileBrowser.use.SendWindowCloseMessage(() => {
    blockingPanel.SetActive(false);
    });

    Save:
    string[] extensions = {"smsf"};
    UniFileBrowser.use.SetFileExtensions(extensions);
    UniFileBrowser.use.SaveFileWindow((string aFilepath) => {
    Debug.LogError("Save");
    });
    UniFileBrowser.use.SendWindowCloseMessage(() => {
    blockingPanel.SetActive(false);
    });

    I've tried commenting out the SetFileExtensions and SendWindowCloseMessage calls, so that the only call is OpenFileWindow, and it still doesn't work. Somehow, calling SaveFileWindow allows OpenFileWindow to work. Any ideas?
     
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You sent that as a support request to my site, so I answered that way.

    --Eric
     
  26. rastleks

    rastleks

    Joined:
    Jul 17, 2014
    Posts:
    49
    Hi.

    Can I use this Asset upload video to application runtime on Android? If so, can I do this without showing the file browser UI, just knowing the path to the file?
     
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Hi, it doesn't do anything except provide a file browser. What you do with the file name string is up to you.

    --Eric
     
  28. Omnikam

    Omnikam

    Joined:
    Nov 26, 2014
    Posts:
    9
    Hey Eric , just bought your File explorer and i have a question about intergrating it into my project (im a noob )
    If i understand right the open file path is stored in "file://" + pathToFile So the string "pathToFile" will contain it?
    Also i have another script that loads movies , it stores the Path to the movie in string StrName . So do i use
    string strName = "+ pathToFile" in my movie script? When i try it it doesnt work, i dont get errors, just no movie loads, i really want to get your pathToFile into my strName, could you help? Im happy pay for your time
    This is my line in my movie script string strName ="file://" + pathToFile;
    i get pathToFile does not exist in current context?
     
    Last edited: Apr 23, 2016
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not "file://", just the path. The path returned by UniFileBrowser is usable as-is, no need for modifications. Have a look at the example script.

    --Eric
     
  30. Omnikam

    Omnikam

    Joined:
    Nov 26, 2014
    Posts:
    9
    I looked at the example script, couldnt understand it :-( if the Path to file is not stored in pathToFile then im at a complete loss. Plus "pathToFile" is not seen in my Script, i just get the error"pathToFile does not exist in current context"
    It seems that your script is not able to share its result with my script, a shame as this looks like a nice product
     
  31. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's a local variable in the function you're using. I'd strongly recommend learning the basics of programming; while UniFileBrowser is easy to use, it does require some programming knowledge.

    --Eric
     
  32. Omnikam

    Omnikam

    Joined:
    Nov 26, 2014
    Posts:
    9
    Well in my MediaPlayer.sc i made filemanager object public and pathToFile public in filebrowser also. I thought this would make pathToFile findable

    public GameObject filemanager;
    public pathToFile;
    public path;


    void Start () {

    filemanager = GameObject.FindGameObjectsWithTag("file");
    path = filemanager.GetComponent<pathToFile>();

    I only need code for 1 part, feeding the Path to file to another script. It`s probably simple to do, but for a noob it`s mount everest :p . Would you be willing to look at it for a fee ,im kinda desperate
     
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Have you read the docs? You pass in your own function to the OpenFileWindow function, and this function that you pass in has a local string variable, which contains the path. This way you tell UniFileBrowser what to do when the user selects a file. Also have another look at the example script, it's pretty basic and isn't many lines of code. In particular look at the OpenFile function, and how the script uses it.

    --Eric
     
  34. Omnikam

    Omnikam

    Joined:
    Nov 26, 2014
    Posts:
    9
    read the docs
    Okay so what your saying is to incorporate UniFileBrowser.use.OpenFileWindow (OpenFileFunction) into my mediaplayer script so the path will be local to my script, i think i get it. Will i still need unifilebrowser on a empty game object?
    i put this in my script, no errors, so i just call OpenFile right?

    public void OpenFile (string pathToFile) {
    var fileIndex = pathToFile.LastIndexOf (pathChar);
    message = "You selected file: " + pathToFile.Substring (fileIndex + 1, pathToFile.Length - fileIndex - 1);
     
    Last edited: Apr 24, 2016
  35. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, that's where you set up the variables for various options, and that's where the instance of UFB lives.

    No, you call UniFileBrowser.use.OpenFileWindow and pass in your OpenFile function. UFB calls your function when the user selects a file.

    --Eric
     
  36. Omnikam

    Omnikam

    Joined:
    Nov 26, 2014
    Posts:
    9
    Got it working :p thanks
     
    Last edited: Apr 24, 2016
  37. Omnikam

    Omnikam

    Joined:
    Nov 26, 2014
    Posts:
    9
    Eric last question, how can i size the font up, on mobile it`s nearly inposible to read, which makes navigation, a magifing glass exersise
    Edit. I can set custom font for the buttons no problem. Im talking about the actual size of the text from the scrollers
    Never Mind, i found an Answer on the review`s page on Asset store
    Great Pluggin
     
    Last edited: Apr 24, 2016
  38. Omnikam

    Omnikam

    Joined:
    Nov 26, 2014
    Posts:
    9
    Eric, Can your FileBrowser be made to work with touchless VR ?
    I really need to be able to Look at it no navigate, but i dont see how as its not really a game object, and i dont think ugui takes raycasts, plus when navigating directorys via the upper left select box you are required to hold down the button, How could this be simulated via gaze control? can your browser be rewritten to Allow gaze control or is it impossable? Your feedback on this matter would be great
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I don't really know anything about how VR works, sorry.

    --Eric
     
  40. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Can u convert c# version?
     
  41. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    Why? It works as is. Why do you NEED it in C#? Just curious.
     
  42. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    because I move all 3rd party dependencies to plugins folder, and I can't because the js has to be in plugin to be compiled first.
     
  43. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Really nice file browser. Few things I can't figure out though.

    How to set the pathChar so It reads up a level.
    so a user can access all hard drives on their computer.

    is there a way to read the resolution and file size of a pic?
    Want to limit it client side.

    and how to enable raycast target on the browser window. Right now you can click through it which is causing issues.
     
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    "../" is up a level, but that has nothing to do with pathChar. To access volumes, check the "Show Volumes" option. As far as pics, UFB is a file browser only; what you do with the data is up to you. Unity reads JPG and PNG files natively using the WWW class, but other than that you'd need to parse image data yourself. For raycasting, you could use GetFileWindowRect and early out if the cursor is inside the rect.

    --Eric
     
  45. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Thanks for the fast reply Eric. I know its a low cost asset and support for it probably sucks lol.
    Not sure why I didn't see volume. That fixes that.
    I'll google how to read the file properties.

    As for the recasting thing. I haven't really used this GUI system in unity.
    I asked this question in the forum yesterday but had no responses yet.
    I think this should be a default in the asset. I don't see any reason why someone would want to click through the window.

    Rect FileBrowserWindowRect = UniFileBrowser.use.GetFileWindowRect();

    what do you mean by early out?
    any chance I could get a small code sample. would really really appreciate it man.
     
  46. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I guarantee that the instant I force a behavior, I will get complaints about it. ;) I think it's much better to stick to Unity defaults, and let people create the behavior they want, which is why tools like GetFileWindowRect exist. By early out I mean return from your raycasting function without doing anything. See the code example in the docs for GetFileWindowRect, but instead of the print statement, you could just stick "return;" in there. That way nothing will happen if the cursor is in the file window. (Also you'd probably want to use FileWindowOpen first to check if the window is open at all.)

    Oh, also it's worth keeping in mind that GetFileWindowRect uses GUI coords, and if by chance you're using Input.mousePosition, that's using screen coords, which is different. The y coord is inverted between those and would require conversion, although it's trivial to do. That's why the code example uses Event.current.mousePosition, which is GUI coords, and is used in OnGUI.

    --Eric
     
  47. rahharya

    rahharya

    Joined:
    Jun 6, 2016
    Posts:
    8
    Halo Eric.
    can I change the Size of the Button depend on the Screen Size.
    I work in Android Platform. and i have different size in each Phones. I think thats because the Pixel for each Phones are different.
    sorry for my bad English. I hope you understand
     
  48. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Sure, set UniFileBrowser.use.buttonSize as desired.

    --Eric
     
  49. rahharya

    rahharya

    Joined:
    Jun 6, 2016
    Posts:
    8
    Thanks for the fast Reply

    I have another Problem. I have bought your OBJReader Asset to. and i dont know how to set the Path that i chose from UniFileBrowser, so my Objfilename have that Path. Capture.PNG

    I tried with PlayerPrefs.SetString("File_Path,Path)
    and in OBJ Reader PlayerPrefs.GetString("File_Path")
    but it show that "File not found"
     
  50. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Try Debug.Log with the path to see if it's what you expect. Also PlayerPrefs is for persistent storage, which isn't really appropriate here. If you have separate scripts, use standard interscript communication functions such as GetComponent. This works fine:

    Code (csharp):
    1. void OpenFile (string pathToFile) {
    2.     ObjReader.use.ConvertFile (pathToFile, true);
    3. }
    I don't know what code you're using for loading, so I can't advise on that. In the future, please post code as code, not as an image.

    --Eric