Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

UniFileBrowser - runtime file browsing

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

  1. rahharya

    rahharya

    Joined:
    Jun 6, 2016
    Posts:
    8
    Thank for the Reply

    this is my Code in UniFileBrowser
    Code (CSharp):
    1. void OpenFile (string pathToFile) {
    2.         ObjReader.use.ConvertFile(pathToFile, true);
    3.         var fileIndex = pathToFile.LastIndexOf (pathChar);
    4.         message = "You selected file: " + pathToFile.Substring (fileIndex+1, pathToFile.Length-fileIndex-1);
    5.         PlayerPrefs.SetString("File_Path", pathToFile);
    6.         Fade();
    7.     }
    and this is my Code in OBJReader
    Code (CSharp):
    1. IEnumerator Start () {
    2.         var loadingText = GameObject.Find("LoadingText").GetComponent<GUIText>();
    3.         loadingText.enabled = true;
    4.         loadingText.text = "Loading...";
    5.         yield return null;
    6.  
    7.         objFileName = PlayerPrefs.GetString("File_Path");
    8.         ObjReader.use.ConvertFile (objFileName, true, standardMaterial, transparentMaterial);
    9.        
    10.         loadingText.enabled = false;
    i dont know whats wrong with it. i have tried it before with Prefab, and it worked. now it show different Path.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Get rid of PlayerPrefs as I suggested, and put a Debug.Log in there so you know exactly what you're dealing with.

    --Eric
     
  3. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    980
    Hey Eric. I have permission issues on Android. Reading internal files.
    Last few days of research says the only way to make it work is using the Android API.
    Adding permissions in manifest doesn't seem to work even though it comes up asking the user to hit accept to read files.

    Your asset keeps saying unable to access /mnt/expand
     
    Last edited: Jul 24, 2016
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    You can try turning off "show volumes", but other than that I don't have any info about Android permissions aside from setting up the manifest appropriately.

    In other news, UniFileBrowser 2.6 is out on my site, and has been submitted to the Asset Store.

    Additions:
    • Scale function for resolution independence.
    • DontScale function if you want to turn Scale off.

    Changes:
    • Requires Unity 4.3 or later.
    • Uses a DLL by default, so any script compilation order issues are bypassed. Source is available in the UniFileBrowserSource package.
    • Assets for the default skin have been moved to UniFileBrowser Assets/Default skin/Resources, since the Reset function uses Resources.Load now.
    • Improved documentation.

    --Eric
     
  5. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    980
    Alright i'll try that. Has it been tested on any android devices?
    I notice that the browser window is really small on mobile maybe the 2.6 version fixes that issue.

    I know people have mention this :p but I really think the asset should be upgraded to the new GUI system. There was a lot of bugs in it when it first release but hardly any now. I know cause my game is 100% New GUI base and it uses every bit of it :p. Its majorly superior. Can also use it dynamically in script too. Really no reason to use the old GUI anymore.
    I honestly don't see to many people using the old GUI anymore. Only unity veteran developers :)

    also if you change to the new GUI you can remove the skin options and window position/size etc... The UniFileBrowser component settings can be reduced by a mass load. I bet it will lower your amount of support for this asset to. I noticed a lot of your support questions are related to the GUI.

    Thanks for updating the asset man. :)
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Yes, people are using it successfully on Android. You can use a GUISkin that's appropriate for a hdpi screen. Also the Scale function could be useful, though you'd still want to be using hdpi assets. I'm not sure what you would expect to gain from using the new GUI system? The IMGUI system is appropriate for heavily programmatic GUIs, which is what UniFileBrowser is (there's a reason the Unity editor uses the IMGUI system). Actually few of the support questions are about the GUI. Most of the component settings aren't related to the GUI, but I wouldn't generally be able to remove many skin or position options anyway, since you still would need to skin and position the window regardless of what system you use. Also, since it would involve a 100% rewrite from scratch, I wouldn't be able to justify it as an upgrade, but would have to make a new asset.

    --Eric
     
  7. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    980
    I've spent hours googling this permission issue though. Really hope its the volume thing other wise no idea how others got around that. According to androids documentation reading files for android requires no permissions. Only if you try to read from a external memory card. That's why im a bit hesitant to believe someone got it working with android :)

    but anyways anything is a lot of work for $10 for a sale :) so its all understandable of course.
    I don't know how you do it honestly.
    will keep you updated in my journey though :)
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Well, see earlier in this thread. In any case UFB just uses standard System.IO functions, nothing unusual.

    --Eric
     
  9. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    980
    hmm. well the issue I have isn't using the files its just simply opening up the file browser. Soon as I open it bam permission issue. So its way before code.



    This was one of the first thing ive tried actually. That's only for external memory cards though.
    PlayerSettings->Android->OtherSettings->WriteAcess
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    When you open the browser, it necessarily needs to get info via System.IO functions; otherwise you'd have a blank window.

    --Eric
     
  11. rahharya

    rahharya

    Joined:
    Jun 6, 2016
    Posts:
    8
    Halo Eric.
    I have get rid the PlayerPrefs. But the Problem still happens.
    Here is the code by the UniFileBrowser

    Code (CSharp):
    1.   void OpenFile (string pathToFile) {
    2.         objfilepath = pathToFile; // i have made a public string objfilepath in Skript.
    3.         Debug.Log("the messege ist" + pathToFile);
    4.         var fileName = Path.GetFileName (pathToFile);
    5.         message = "You selected file: " + fileName;
    6.         Fade();
    7.        
    8.        
    And i have a new UI

    Code (CSharp):
    1.   if (GUI.Button(new Rect(100, 275, 95, 35), "View"))
    2.         {
    3.             //SceneManager.LoadScene(1);
    4.             Debug.Log("the messege ist" + objfilepath);
    5.         }
    but still, i dont get the Path that i want.

    Capture.PNG
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    I would assume that you're not running the OpenFile function, or something else is altering the objfilepath variable. If you run the OpenFile function, the pathToFile parameter contains the full path of the file that the user selected.

    --Eric
     
  13. rahharya

    rahharya

    Joined:
    Jun 6, 2016
    Posts:
    8
    i don't know anymore what should i do here.
    I have tried to solve this problem since 3 Month.
    could you try it? since the both asset i bought from you
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    It works fine. Like I posted above:

    Code (csharp):
    1. void OpenFile (string pathToFile) {
    2.     ObjReader.use.ConvertFile (pathToFile, true);
    3. }
    That's all there is to it.

    --Eric
     
  15. KKman3895

    KKman3895

    Joined:
    Aug 24, 2016
    Posts:
    2
    Hi,

    I would like to edit the Source Code.
    How do I edit the DLL??
    had a look at the instruction but still very confused.
    Can you please explain again?

    Cheers
    KK
     
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    The DLL is not something you can edit. Remove it, and import the source package instead. That's really all there is to it. The instructions in the docs also cover how to fix the missing reference that occurs if you had UniFileBrowser attached to an object before removing the DLL.

    --Eric
     
  17. KKman3895

    KKman3895

    Joined:
    Aug 24, 2016
    Posts:
    2
    Oh cool.
    Now I can see the source package.
    before when I downloaded it, It wasn't there.
    make sense now.

    Cheers
     
  18. setford

    setford

    Joined:
    Oct 21, 2016
    Posts:
    4
    How to change font size, fond sizes for folder names and file names are too small ?

    Thanks
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Change the font size in the listScrollView and popupButton styles.

    --Eric
     
  20. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    719
    Anyone having problems since moving to Unity5.5 beta? got quite a few compile errors now.
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    There's a couple warnings about WP8Player being obsolete (which doesn't affect anything and they are warnings, not errors), but other than that there are no problems and it works fine.

    --Eric
     
  22. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    719
    Not for me, I have had to comment out the majority of the code making it unusable. It could not find "UniFileBrowser" which is used staticly quite a bit.
     
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    There are no differences between Unity 5.4 and 5.5 that are relevant to UniFileBrowser; the code works exactly the same. In order to use UFB, it needs to be attached to an object, so perhaps you accidentally removed it?

    --Eric
     
  24. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    719
    is there a c sharp version of the code I could work out whats goign wrong then.
     
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    No; perhaps you moved the script out of the Plugins folder. Also try using the dll instead.

    --Eric
     
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Small update out now on my site (submitted to the asset store a few minutes ago):

    UniFileBrowser 2.6.1

    Fixes:
    • Fixed word wrap in the message window.
    • Removed references to WP8 to avoid warnings in newer versions of Unity.
    • DLL works with Unity 5.5.

    --Eric
     
  27. LemonKetchup

    LemonKetchup

    Joined:
    Dec 27, 2016
    Posts:
    1
    I just upgraded unity 3d from 5.4 to 5.5, but UnifileBrowser is not recognized, please check and advise
    thanks
     
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Update to the latest version.

    --Eric
     
  29. jayrbyam

    jayrbyam

    Joined:
    Dec 28, 2016
    Posts:
    6
    Hi! I've updated to 5.5 and thought all was running smoothly, but then I realized calling UniFileBrowser.use.OpenFileWindow() causes a NullReferenceException to be thrown from UniFileBrowser.GetCurrentFileInfo(). I know it worked before. Am I missing something here?

    Thanks in advance.
     
  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Running fine with 5.5 here; do you know where in GetCurrentFileInfo it's not working?

    --Eric
     
  31. jayrbyam

    jayrbyam

    Joined:
    Dec 28, 2016
    Posts:
    6
    I'm afraid this error message is all I get:
    NullReferenceException: Object reference not set to an instance of an object
    UniFileBrowser.GetCurrentFileInfo ()
    UniFileBrowser.ShowFileWindow ()
    UniFileBrowser.OpenFileWindow (CompilerGenerated.__UniFileBrowser_multiDelegate$callable1$118_29__ openFileFunction)
     
  32. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    I would need the line number of the script where the error occurs to have something to go on.

    --Eric
     
  33. jayrbyam

    jayrbyam

    Joined:
    Dec 28, 2016
    Posts:
    6
    I understand that, but that message is all I get. Any suggestions on where to go from here?
     
  34. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    If you're using the DLL, use the source instead.

    --Eric
     
  35. jayrbyam

    jayrbyam

    Joined:
    Dec 28, 2016
    Posts:
    6
    Okay, where can I get the source? It doesn't appear to be in the package on the Asset Store.
     
  36. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    It's definitely included.

    Screen Shot 2017-01-02 at 12.42.10 PM.png

    --Eric
     
  37. jayrbyam

    jayrbyam

    Joined:
    Dec 28, 2016
    Posts:
    6
    Missed that! Thanks for your patience.
    This is now the error message I get:
    NullReferenceException: Object reference not set to an instance of an object
    UniFileBrowser.GetCurrentFileInfo () (at Assets/Plugins/UniFileBrowser/UniFileBrowser.js:1097)
    UniFileBrowser.ShowFileWindow () (at Assets/Plugins/UniFileBrowser/UniFileBrowser.js:1170)
    UniFileBrowser.OpenFileWindow (CompilerGenerated.__UniFileBrowser_multiDelegate$callable1$118_29__ openFileFunction) (at Assets/Plugins/UniFileBrowser/UniFileBrowser.js:1145)
     
  38. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Not sure how it could be null, but try changing the line "multiFileList.Clear();" to

    Code (csharp):
    1. if (multiFileList == null) {
    2.     multiFileList = new List.<int>();
    3. }
    4. multiFileList.Clear();
    --Eric
     
  39. jayrbyam

    jayrbyam

    Joined:
    Dec 28, 2016
    Posts:
    6
    That did the trick. Thanks very much!
     
  40. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    980
    Has anyone been able to get this to work with WEB GL
     
  41. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    It can't work with WebGL (or the old webplayer) since there are security restrictions in accessing local files in those cases.

    --Eric
     
  42. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    980
    I thought webGl was nothing like the old webplayer. It just use html5 and javascript? It uses browser native code I thought.
     
  43. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Regardless, it has no access to local files due to security restrictions.

    --Eric
     
  44. DennyFarts

    DennyFarts

    Joined:
    Nov 23, 2016
    Posts:
    3
    Hi Eric,
    I'm 11 and new at this and need your help on something. I have successfully used the plugin for my app and I have the permissions working and everything. The problem is when the file search is opened on a mobile device the font is tiny (especially on my Dad's phone that is QHD). How do I increase or scale the font size up once I am in the open file window? Thanks and sorry if this is really basic, but I tried all of the settings I could find.
     
  45. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Settings for fonts and stuff in the GUISkin are in the skin itself. It looks like you're using the default skin, so that means UniFileBrowserGUISkin in the default skin folder. For example, the font size for the file list is in the listScrollview custom style. The font size for that style is set to 0 normally, which uses the default size, so you can change it to a larger size instead. Probably 20 or 30 would work well.

    --Eric
     
  46. DennyFarts

    DennyFarts

    Joined:
    Nov 23, 2016
    Posts:
    3
    Thank You
     
  47. FFozzy

    FFozzy

    Joined:
    Oct 22, 2015
    Posts:
    4
    Sorry for the thread necro, but this is still occurring on OSX specifically. You can't ignore this if it's in MonoDevelop, as it prevents Mono from being able to debug a unity project. Works fine in Windows / Visual Studio. Do you need to add some Boo dll or something for osx?
     
  48. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Try editing the references and adding Boo.Lang.

    --Eric
     
  49. FFozzy

    FFozzy

    Joined:
    Oct 22, 2015
    Posts:
    4
    Thanks! Tried that, but alas, it did not get rid of the error.
     
  50. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,899
    Hmm...I just tried it, and it did get rid of the error.

    --Eric