Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

File Browser - Native file browser

Discussion in 'Assets and Asset Store' started by Stefan-Laubenberger, Dec 28, 2017.

  1. Kyle_MT

    Kyle_MT

    Joined:
    Aug 8, 2022
    Posts:
    4
    Hi Stefan,

    When I open one of those Demo Scenes imported from Demos.unitypackage, many Prefabs are missing. I assume these Prefabs should have already been packed along with unitypackage, but something goes wrong. Could you please help to confirm the integrity of the Prefabs?
    upload_2022-9-27_17-12-31.png
     
    Last edited: Sep 27, 2022
  2. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,912
    Please also install the "Demos.unitypackage" - does that solve the issues with the prefabs?
     
  3. Kyle_MT

    Kyle_MT

    Joined:
    Aug 8, 2022
    Posts:
    4
    Thanks! That solves the issues, we found that some packages are missing because they are ignored in version control.

    In the WebGL_Demo scene, I found a pre-setup Prefab called FileBrowser that uses a Custom Wrapper FileBrowserWebGL, so I build a WebGL player with the same setup included in my scene. However, some errors occur when FileBrowser.Instance.OpenSingleFile is called:

    exception thrown: TypeError: document.convertPtrToString is not a function
    ...
    An abnormal situation has occurred: the PlayerLoop internal function has been called recursively.

    A more detailed log file can be found in the attachment.
    Also, I notice that if FileBrowser.Instance.OpenSingleFolder is called, then the property of FileBrowserWebGL canOpenFolder always returns false. Do I have to implement it myself? Thanks.
     

    Attached Files:

    Last edited: Sep 28, 2022
  4. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,912
    The error for "OpenSingleFile" seems to happen in the WebGL-asset from FrostweepGames - please talk to them for a solution since our asset just uses it.
    The same is true for the folder support - afaik it's not possible under WebGL to open a folder for security reasons. Only opening and saving files is possible.
     
  5. Kyle_MT

    Kyle_MT

    Joined:
    Aug 8, 2022
    Posts:
    4
    Appreciate your help!
     
  6. EvanBottango

    EvanBottango

    Joined:
    Aug 19, 2018
    Posts:
    9
    Hi, sorry if this has already been addressed, didn't see it in the forum. Is there a way to have the open file prompt, when given multiple extensions in the extension filter allow for all files of the given extension type to be able to be selected? Ex: if extensions ".wav" and ".mp3" are passed, all .wave and .mp3 files can be selected, not just the file type from the dropdown on the open dialog? I've gotten some reports of confusion from my users on this, and didn't see anything in the docs that would enable that behavior.

    Edit: It works on mac os in the editor how I want, all file types are valid selections in the extension filter, but on builds, you can only select one file type at a time from a dropdown.
     
    Last edited: Oct 25, 2022
  7. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,912
    Hi

    You can use the "ExtensionFilter"-class, like this:
    Code (CSharp):
    1. ExtensionFilter[] extensions = { new ExtensionFilter("Audio Files", "wav", "mp3", "ogg"), new ExtensionFilter("Image Files", "png", "jpg", "jpeg") };
    2.  
    3. string path = FileBrowser.Instance.OpenSingleFile("Open file", "", "", extensions);
    I hope this helps you further.


    Cheers
    Stefan
     
  8. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    184
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Crosstales.FB.EditorIntegration.ConfigBase.showPlatformNotSupported () (at Assets/Plugins/crosstales/FileBrowser/Scripts/Editor/Integration/ConfigBase.cs:459)
    3. Crosstales.FB.EditorIntegration.ConfigBase.showConfiguration () (at Assets/Plugins/crosstales/FileBrowser/Scripts/Editor/Integration/ConfigBase.cs:43)
    4. Crosstales.FB.EditorIntegration.ConfigWindow.OnGUI () (at Assets/Plugins/crosstales/FileBrowser/Scripts/Editor/Integration/ConfigWindow.cs:68)
    5. UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) (at <c28615bd9d064a898de518f6614c5ab0>:0)
    6. UnityEditor.DockArea.DrawView (UnityEngine.Rect dockAreaRect) (at <c28615bd9d064a898de518f6614c5ab0>:0)
    7. UnityEditor.DockArea.OldOnGUI () (at <c28615bd9d064a898de518f6614c5ab0>:0)
    8. UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    9. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    10. UnityEngine.UIElements.IMGUIContainer.DoIMGUIRepaint () (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    11. UnityEngine.UIElements.UIR.RenderChainCommand.ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams drawParams, System.Single pixelsPerPoint, System.Exception& immediateException) (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    12. Rethrow as ImmediateModeException
    13. UnityEngine.UIElements.UIR.RenderChain.Render () (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    14. UnityEngine.UIElements.UIRRepaintUpdater.Update () (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    15. UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    16. UnityEngine.UIElements.Panel.UpdateForRepaint () (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    17. UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    18. UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    19. UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    20. UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    21. UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <6dc2316246674edf8a7b6a39a0c405c8>:0)
    22. System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ce684c3e0df64d06ab6e471b9b78c4aa>:0)
    23. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    24. System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ce684c3e0df64d06ab6e471b9b78c4aa>:0)
    25. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <ce684c3e0df64d06ab6e471b9b78c4aa>:0)
    26. System.Delegate.DynamicInvokeImpl (System.Object[] args) (at <ce684c3e0df64d06ab6e471b9b78c4aa>:0)
    27. System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) (at <ce684c3e0df64d06ab6e471b9b78c4aa>:0)
    28. System.Delegate.DynamicInvoke (System.Object[] args) (at <ce684c3e0df64d06ab6e471b9b78c4aa>:0)
    29. UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <a2a9709fa05041918eaa8aec1522e6da>:0)
    30.  
    This was on 2023.1.0a15..... was working fine on a12
     
    Last edited: Oct 27, 2022
  9. ZoroSrk

    ZoroSrk

    Joined:
    Mar 16, 2021
    Posts:
    6
    Hi,
    We are building a MacOS build to upload to TestFlight. During the verification process of test flight we are facing this issue where it says

    "Asset validation failed (90334)
    Invalid Code Signature Identifier. The identifier "com.crosstales.fb" in your code signature for "FileBrowser" must match its Bundle Identifier "com.crosstales.fb.20221104094945" (ID: 1abd978f-a944-422e-a9f9-1df24a8263d1)".

    Unity version : 2020.3.21f1
    Asset version : 2022.2.0 (Used the FileBrowser_macOS_old present in the Libraries/macOS Folder)
    Device used to build : M1 silicon macOS Montesery version 12.4
    Xcode version : 14.0.1

    Please ket me know if I am missing something, Thanks in advance.
     
  10. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,912
    Hi

    Please disable "Modify Bundle" in the configuration and try again:
    upload_2022-11-4_9-44-17.png

    If that still fails, please follow chapter 8.2 in the documentation.


    Cheers
    Stefan
     
    AviarLabs and ZoroSrk like this.
  11. ZoroSrk

    ZoroSrk

    Joined:
    Mar 16, 2021
    Posts:
    6
    Hey, I was able to upload the build to TestFlight using the chapter 8.2 in the documentation but after downloading the app from TestFlight non of the Dialogs open. There are no errors or logs thrown but it seems to not open dialogs when the functions are called.
    The build was downloaded on to an M1 device with macOS Monterey - Version 12.4
     
  12. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,912
    Does the app work locally, before uploading to the store?
     
  13. ZoroSrk

    ZoroSrk

    Joined:
    Mar 16, 2021
    Posts:
    6
    Yes the .app build works locally, but when uploaded to the store and then downloaded this issue happens.
     
  14. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    184
    Have you shrunk some of the example/asset logo images? I noticed my android build was getting bundled with a bunch oversized File browser images I had no need or want for in my build... why was that stuff even getting bundled?!
     
  15. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,912
    Hi

    Have you imported our demo scenes? This could be the reason you see some of the logos. If so, please delete the demos. In case that doesn't work, please show me more information so we can investigate the issue.

    Cheers
    Stefan
     
  16. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    184
    The logo1024x1024.png is almost 1mb ... I've gone through applied compression and resolution changes to some of it.. but not sure why alot of that stuff is even there.... like why custom fonts? there is only 1 build scene so far but its not even using File browser stuff right now... just think it could do with more of a cleanup unless the above version is a the project cleanup that sorts out some of this stuff.. especially the custom fonts and larger image files that seem bit large for what is really required but getting bundled.
     
  17. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,912
    As I suspected, you imported our Demos-package.
    If you don't want to have any assets from there, just delete "Plugins/crosstales" and re-import the asset.
    We especially made the demo scenes in a separate package for that reason.
     
    Slashbot64 likes this.
  18. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    184
  19. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    184
    shame there isn't a special demo example folder in unity for things like that can go into and be in editor but not in builds
     
  20. mikecaputo

    mikecaputo

    Joined:
    Jul 9, 2017
    Posts:
    18
    It sounds like you're being passive aggressive about them not creating an "Editor" folder.
     
  21. Geefa

    Geefa

    Joined:
    May 22, 2022
    Posts:
    1
    Hello,
    Love this plugin! Does everything as advertised and the available documentation makes so simple.

    However, I am struggling with something (excuse me if I sound novice). I have made an array of 2 RawImages, I want to upload two images from my files and loop through these RawImages' textures (I.e assign the first selected image to be the texture of the first RawImage in the array and the second to the other one.)

    What happens with my code is both RawImages in the array get assigned the same texture/image and I am not sure how I can loop through my selected files and give them separate textures.

    My code:

    Code (CSharp):
    1. public class OpenFile : MonoBehaviour
    2. {
    3.    
    4.  
    5.     public RawImage[] rawImage;
    6.  
    7.  
    8.     public void OpenFiles()
    9.     {
    10.         string[] extensions = { "jpg" };
    11.         string[] paths = FileBrowser.Instance.OpenFiles("Open file", "", "",
    12.        extensions);
    13.         foreach (string path in paths)
    14.         {
    15.             Debug.Log("Selected file: " + path);
    16.             StartCoroutine(LoadImage(path));
    17.         }
    18.  
    19.  
    20.        
    21.  
    22.  
    23.  
    24.  
    25.     }
    26.  
    27.     IEnumerator LoadImage(string path)
    28.     {
    29.         using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(path))
    30.         {
    31.             yield return uwr.SendWebRequest();
    32.  
    33.             if (uwr.isNetworkError || uwr.isHttpError)
    34.             {
    35.                 Debug.Log(uwr.error);
    36.             }
    37.             else
    38.             {
    39.                 var uwrTexture = DownloadHandlerTexture.GetContent(uwr);
    40.  
    41.                 for (int i = 0; i < rawImage.Length; i ++)
    42.                 {
    43.                     rawImage[i].texture = uwrTexture;
    44.                    
    45.                 }
    46.                
    47.  
    48.             }
    49.         }
    50.     }
    51.  
    52.  
    53. }
    54.  

    using IEnumerator and UnityWebRequest was the easiest thing I found online, feel free to recommend another way you prefer as I didn't quite get what I needed in the documentation.

    Thanks heaps!!
     
  22. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,912
    Hi

    The problem was that you assigned all RawImages in the LoadImage-method.
    Here is a fixed version, I hope it works for you:
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using UnityEngine;
    4. using UnityEngine.Networking;
    5. using UnityEngine.UI;
    6. using Crosstales.FB;
    7.  
    8. public class OpenFile : MonoBehaviour
    9. {
    10.    public RawImage[] rawImage;
    11.  
    12.    public void OpenFiles()
    13.    {
    14.       string[] extensions = { "jpg" };
    15.       string[] paths = FileBrowser.Instance.OpenFiles("Open file", "", "", extensions);
    16.  
    17.       if (paths != null)
    18.       {
    19.          if (paths.Length > rawImage.Length)
    20.             Debug.LogWarning("More images than RawImages selected!");
    21.  
    22.          if (paths.Length < rawImage.Length)
    23.             Debug.LogWarning("Less images than RawImages selected!");
    24.  
    25.          for (int index = 0; index < Mathf.Min(paths.Length, rawImage.Length); index++)
    26.          {
    27.             string path = paths[index];
    28.             Debug.Log("Selected file: " + path);
    29.             StartCoroutine(LoadImage(path, index));
    30.          }
    31.       }
    32.       else
    33.       {
    34.          Debug.Log("No files selected!");
    35.       }
    36.    }
    37.  
    38.    IEnumerator LoadImage(string path, int index)
    39.    {
    40.       using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(path))
    41.       {
    42.          yield return uwr.SendWebRequest();
    43.  
    44.          if (uwr.isNetworkError || uwr.isHttpError)
    45.          {
    46.             Debug.Log(uwr.error);
    47.          }
    48.          else
    49.          {
    50.             rawImage[index].texture = DownloadHandlerTexture.GetContent(uwr);
    51.          }
    52.       }
    53.    }
    54. }
    55.  
    Cheers
    Stefan


    Edit:
    This version is imho sweeter:
    Code (CSharp):
    1. using Crosstales;
    2. using UnityEngine;
    3. using UnityEngine.UI;
    4. using Crosstales.FB;
    5.  
    6. public class OpenFileV2 : MonoBehaviour
    7. {
    8.    public RawImage[] rawImage;
    9.  
    10.    public void OpenFiles()
    11.    {
    12.       string[] extensions = { "jpg" };
    13.       string[] paths = FileBrowser.Instance.OpenFiles("Open file", "", "", extensions);
    14.  
    15.       if (paths != null)
    16.       {
    17.          if (paths.Length > rawImage.Length)
    18.             Debug.LogWarning("More images than RawImages selected!");
    19.  
    20.          if (paths.Length < rawImage.Length)
    21.             Debug.LogWarning("Less images than RawImages selected!");
    22.  
    23.          for (int index = 0; index < Mathf.Min(paths.Length, rawImage.Length); index++)
    24.          {
    25.             string path = paths[index];
    26.             Debug.Log("Selected file: " + path);
    27.             rawImage[index].texture = System.IO.File.ReadAllBytes(path).CTToTexture();
    28.          }
    29.       }
    30.       else
    31.       {
    32.          Debug.Log("No files selected!");
    33.       }
    34.    }
    35. }
     
    Last edited: Jan 13, 2023
  23. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,912
    We've just released version 2023.1.0 of File Browser.
    Main changes:
    • Windows: number of maximal selected files and folders is changeable
    • Linux: various fixes, fallback for SaveFile
    • Support for Unity 2023
    • Updated to Common 2023.1.0
     
  24. mayquartet

    mayquartet

    Joined:
    Dec 7, 2021
    Posts:
    2
    I want to use WebGL_Demo in 3rd party dir. But when I build this to WebGL and run, It has Error like this. I found problem like this in forum but they said "FrostweepGames" folder and I don't have that. What should I do?

    upload_2023-2-2_16-30-17.png
     
  25. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,912
  26. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    323
    Cool asset. You should probably make more clear on the asset page that WebGL support isn't out of the box but needs an additional purchase.
     
  27. mayquartet

    mayquartet

    Joined:
    Dec 7, 2021
    Posts:
    2

    Thank you for your help, Stefan.
    I solved that problem but I have another problem now.

    I want to open the file with WebGL and get the file data (byte array) of the file.
    So, I used code like this.
    upload_2023-2-6_13-55-22.png

    I want to open a file using GetOpenFilePath() and import data using CurrentOpenSingleFileData.
    After that, I want to process this data and use SaveFileAsync of SetSaveFilePath().

    This code works properly in the editor. However, WebGL encounters the following error:
    upload_2023-2-6_13-48-50.png

    I checked the error and it seems that WEBGL did not receive the CurrentOpenSingleFileData and has a null value.

    The problem is difficult to detect in the Editor because the code works normally.
    There seems to be a problem with the WebGL part, so please find out what I missed.

    Thank you.