Search Unity

UniFileBrowser - runtime file browsing

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

  1. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    New update!

    UniFileBrowser 2.5

    Additions:
    • SetWindowPosition and SetWindowSize functions, for setting the file window position/size through code.

    Changes:
    • Touch input with mobile devices is improved; specifically, lists can be scrolled by touch-dragging instead of having to use the scroll bar.
    • When using the "open folder" functionality, the "Select" button will work with a selected/highlighted folder. If no folders are highlighted, then it uses the current folder as usual.

    --Eric
     
  2. KnuckleCracker

    KnuckleCracker

    Joined:
    Dec 27, 2011
    Posts:
    81
    I've a moderate, though annoying, issue I've discovered. Things work great and fine so long as I'm using MonoDevelop. But, like a lot of people now that MS has made Visual Studio 2013 free I've jumped over to using that along with UnityVS. Things are great... but not so much with UniFileBrowser.

    The problem is that being in written in javascript and having functions that take 'delegates' seems to be the one thing (the one I have discovered anyway) that just doesn't work when using UnityVS and visual studio.

    As an example Visual Studio will show syntax errors when I try to call UniFileBrowser.use.OpenFileWindow. This is because Visual Studio doesn't know that function exists. Now it isn't as simple as no functions in UniFileBrowser.js show up... most in fact do. It is just the function where the argument is "function(String)" that don't show up.
    It looks like UnityVS (or something) creates mappings into js functions so they can be seen by c# in visual studio. But not for functions with these argument types.

    The old (really old) version of UniFileBrowser didn't use delegates but instead required an object that it could call SendMessage on. I certainly understand the switch to function pointers / delegates. If UniFileBrowser were in C# there wouldn't be any issue either.

    Now I fully understand that you could probably care less, since things work fine in monodevelop and compile just fine in Unity. But I wanted to mention this issue since I won't be the only one to jump on the UnityVS and Visual Studio bandwagon now that it is all free.

    Lastly, I'm not sure what I'll do. Looks like I might have to switch my copy back to not using delegates or figure out a way to create some other function to pass the function call (things I've tried so far don't work). Living with several red errors showing up at the bottom of visual studio for eternity isn't something I'm keen on, so I'll do something....
     
    Demigiant likes this.
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Maybe compiling to DLL would bypass the issue, since a DLL is a DLL regardless of source language. In this case there would need to be at least a couple of DLLs to account for the conditional compilation.

    --Eric
     
  4. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi @Eric5h5, I get this same error immediately after entering play mode, whenever I click the mouse or press a key. I just bought UniFileBrowser and am on the latest Unity 4.6.0f3. I see that error doesn't happen in your demo scene, but I can't fathom why. Any trick to avoid it?

    EDIT: by the way, the error happens only when the FileWindow is not open
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It was a bug added to Unity sometime in the 4.x cycle; using GUI.SetNextControlName triggers it in some circumstances. I kind of need to use that, so short of Unity fixing the bug I'm not sure what can be done.

    --Eric
     
  6. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Ouch. Has the bug been reported? Other than that, the mystery was that the error didn't happen in your demo. I investigated more and apparently that error doesn't happen as long as you have an active OnGUI method (even empty, as long as it's not in a disabled Component). I added an empty OnGUI method to my scene's "brain" and error no more.
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, I reported the bug in March 2013, but it's still open.

    --Eric
     
  8. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    That OnGUI kind-of-fix is pretty useful though (way better than a flood of errors, even if harmless): you might want to add it to the documentation since there's no other solution right now ;)
     
  9. hermit_purple

    hermit_purple

    Joined:
    Jun 27, 2014
    Posts:
    11
    Is there a way to show file size in the browser?
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not currently.

    --Eric
     
  11. puargs

    puargs

    Joined:
    Apr 30, 2013
    Posts:
    10
    Hey man good product. Just a note - the documentation states that your new function names are "SetWindowSize" and "SetWindowPosition" but they are actually "SetFileWindowSize" and "SetFileWindowPosition".
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Oops, good catch! Thanks, I'll fix that.

    --Eric
     
  13. puargs

    puargs

    Joined:
    Apr 30, 2013
    Posts:
    10
    One other thing - it's something I put into your code myself, but it's just a suggestion if you want to use it. Could you add optional delegates for when CloseFileWindow gets called? This way I can track when cancel is hit vs choosing to open the file.

    To explain why I needed to implement this myself (it's just a few lines, works fine), I use NGUI primarily for all my other GUI-based functionality. In order to avoid clickthrough (clicking on something in default Unity GUI and having it *also* click the item below it in NGUI), I have to be able to disable the NGUI elements when the regular GUI elements are open.
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That sounds reasonable.

    --Eric
     
  15. Boegi

    Boegi

    Joined:
    Dec 6, 2014
    Posts:
    19
    Hi Eric,
    I purchased your FileBrowser some days ago and I can't get it to work on Android (5.0.2). (I'm SURE IT's MY FAULT - Your Filebrowser is awesome)

    I get...
    Error: Access to the path /data/data/ is denied (All the Time)

    Can you please point me to the right direction? I guess this is a permisson thing (Maybe Android Manifest needs extra permissions?) Or it might be because the new Android versions do not read from SD cards / need special stuff?

    I would be really happy if you can point me to the right direction. There are so many possibilities and I guess you have heard once before.

    Thanks..

    PS: I have a rooted and a nonrooted Version of the Nexus7 I'm testing with (both the same Version -> Same Result)
    I have added extra Manifest file with permissions to my Unity Project -> I can't see, if the "build" apk contains the permissions? (The manifest.xml file is "human unreadable" in notepad++ and some other editors I checked)

    Update: I want to read a file (*.mp3) from an android device... (Not write)
     
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Possibly related to this? Other than that, UFB will read from anywhere you have permission to access, but it can't bypass permissions (not a 1337 haxx0r tool, sorry ;) ).

    --Eric
     
  17. Kiori

    Kiori

    Joined:
    Jun 25, 2014
    Posts:
    161
    Does it work on windows phone, android and ios? Specially windows phone 8.1+.
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    iOS and Android yes; I haven't tested WP but as far as I know there's no reason it wouldn't (no reports so far about not working).

    --Eric
     
  19. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Is unity ever going to fix the !dest.m_MultiFrameGUIState.m_NamedKeyControlList bug? Its been around since World War 2 and its still here in Unity 4.6.2p2. I've had issues with it on multiple onGUI assets.
     
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I sure wish there would be. It may help if you submit a bug report (with a repro project). I already have of course, long ago and still listed as open, but more couldn't hurt.

    --Eric
     
  21. vismonkey

    vismonkey

    Joined:
    Jul 23, 2013
    Posts:
    7
    You mentioned quite a while back that you were able to integrate uniFileBrowser with Playmaker. Im completely new to Playmaker and coding and it would be greatly appreciated if you could share the FSM actions.
     
  22. Eric-Pratt

    Eric-Pratt

    Joined:
    Apr 28, 2014
    Posts:
    30
    I'm having trouble adjusting the window size in Android, it seems to be ignoring the default values which adjust the window size in Windows? And any hints about how to set a starting directory would be helpful too ie start in DCIM. Thanks,
     
    Last edited: Mar 17, 2015
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm not sure about Android, but it works as expected in iOS. I can't see anything that would cause any different behavior.

    --Eric
     
  24. Eric-Pratt

    Eric-Pratt

    Joined:
    Apr 28, 2014
    Posts:
    30
    The window is too large. In defaults I have it set to 300x400 and testing on the PC it respects that but building it to android the window has to be 1400x1400 (the buttons are off the bottom of the screen is my main problem)
     
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    UFB has code which prevents the window from being placed off-screen, so the only thing I can think of is that Screen.width/Screen.height are returning completely wrong values.

    --Eric
     
  26. Eric-Pratt

    Eric-Pratt

    Joined:
    Apr 28, 2014
    Posts:
    30
    I think you're right, I remarked this:
    defaultFileWindowRect = Rect((Screen.width / 4) * 1.3, (Screen.height / 4) * 0.5, (Screen.width / 4) * 1.7, (Screen.height / 4) * 3.0);
    And I was able to get predictable sizes. This was on a GS5 if that helps.
    Is there any way to start the browser in a particular folder?
     
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Use the SetPath function.

    --Eric
     
  28. Eric-Pratt

    Eric-Pratt

    Joined:
    Apr 28, 2014
    Posts:
    30
    Did the trick, thanks for the great product!
     
  29. Gregle

    Gregle

    Joined:
    Apr 2, 2015
    Posts:
    5
    Hey Eric,

    Awesome support thread and really liking the product. Bit of a noob to Unity and I have a couple questions that you might be able to help me with. I'm building an android game that lets user use their own music files as the soundtrack. Is there a way to set the default view to MediaStore.Audio? Also when I open the folder view in the android app it pops up an error saying access to a specific path is denied. Is there a way to stop this error that I'm missing? I'm almost certain the problems on me. Thanks in advance for any guidance you can give my ignorant self.

    ~Gregle
     
  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use the SetPath function to set the default path, but if you don't have permission for a specific path, I'm afraid there's nothing that Unity can do about that. You need to supply a path that's user-accessible.

    --Eric
     
  31. Gregle

    Gregle

    Joined:
    Apr 2, 2015
    Posts:
    5
    Thanks for the help Eric. Part of the issue was me wanting a path that didn't exist in the Android system haha. I got it working well enough though. Thank you again!
     
  32. Gregle

    Gregle

    Joined:
    Apr 2, 2015
    Posts:
    5
    Hopefully one last question,

    Can you think of reason why everything works great when it's an android development build but the browser throws an error when it's a release build? I'm kind of at a loss here.
     
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    What's the error?

    --Eric
     
  34. Gregle

    Gregle

    Joined:
    Apr 2, 2015
    Posts:
    5
    It opens an error window when it's a release build but not during a development build. I'm not sure what the best way to go about debugging it is.
     

    Attached Files:

  35. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, it's hard to know what the problem is without an actual error message. In the UniFileBrowser script, in the HandleError function, try putting "Debug.Log ("Actual error is: " + errorMessage);" as the first line. Then check the log for the actual error, if it's just somehow not getting displayed in the app for some reason.

    --Eric
     
  36. Gregle

    Gregle

    Joined:
    Apr 2, 2015
    Posts:
    5
    Awesome, thanks for the help Eric. I was able to debug it further and solved the issue. your support of this plugin has been wonderful
     
  37. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Hi Eric,

    I just purchased UniFileBrowser and imported in my project. I can run your demo scene, but when I jump into Mono I got lots of compiler errors. Do you know what I'm missing here (didn't move any file/folder)?

     
  38. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You should compile in Unity, not MonoDevelop.

    --Eric
     
  39. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    How' that? I usually invoke build while in MonoDevelop to discard errors. My project has thousands of lines in C# and +100 classes. I can't change my workflow just for one js file. Is this normal in Unity?

    EDIT: Eric, do you have a C# or DLL version of the script ? I fear I won't be able to use this asset if it breaks my work inside MonoDevelop. Is it strange since I have other js files in my project (which adds some functionality to the Editor), and this problem doesn't occur.
     
    Last edited: May 8, 2015
  40. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,905
    Thanks Eric for the stub. Problem solved.

    Now, the Save/Open Window is not centered on the screen when shown and even worse it exceeds screen dimensions. See attached. Is this a bug or something I have missed?
    Thanks.
     

    Attached Files:

  41. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You'd need to use "maximize on play"; the game window in Unity doesn't get scaled.

    --Eric
     
  42. Killaflow

    Killaflow

    Joined:
    May 9, 2015
    Posts:
    4
    How do I set the default path. it appears to be going back 1 folder when i try to set the path.
    I just added my folder to the provided function:

    Function SetDefaultPath () {
    filepath = Application.dataPath + "/" + "CustomLevels";
    .....

    It shows the path "CustomLevels is in. How do I set the path to inside "CustomLevels"?
     
  43. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Use the SetPath function in UniFileBrowser.

    --Eric
     
  44. Killaflow

    Killaflow

    Joined:
    May 9, 2015
    Posts:
    4
    and i just had to add a + "/" to get the right path.
    filepath = Application.dataPath + "/" + "CustomLevels" + "/";
     
  45. Killaflow

    Killaflow

    Joined:
    May 9, 2015
    Posts:
    4
    Also I get this error:
    !dest.m_MultiFrameGUIState.m_NamedKeyControlList
    The error is a red error, but it does seem to get in the way of anything.
    Also the error occures when i press any ui button in unity(v4.6).
    Just curious if you know the reason.

    Also the error occurs in different scenes, before the UniFileBrowserManager is ever created.
    Error first occured when I imported UniFileBrowser.
     
  46. Killaflow

    Killaflow

    Joined:
    May 9, 2015
    Posts:
    4
    This program is perfect, sorry im an idiot. :/
    I still have this error anytime I make a mouse click.
    Error: !dest.m_MultiFrameGUIState.m_NamedKeyControlList
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
  48. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    Does this work with 5.0+?
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Of course.

    --Eric
     
  50. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    When I run the example scene I only get a very tiny box in the upper left when I hit open, how do I fix that?