GithubHelp home page GithubHelp logo

unitysimplefilebrowser's Introduction

Unity Simple File Browser

screenshot

Available on Asset Store: https://assetstore.unity.com/packages/tools/gui/runtime-file-browser-113006

Forum Thread: https://forum.unity.com/threads/simple-file-browser-open-source.441908/

Discord: https://discord.gg/UJJt549AaV

GitHub Sponsors ☕

FEATURES

  • Behaves similar to Windows file chooser
  • Ability to search by name or filter by type
  • Quick links
  • Simple user interface
  • Draggable and resizable
  • Ability to choose folders instead of files
  • Supports selecting multiple files/folders
  • Can easily be reskinned
  • Supports runtime permissions on Android M+ and Storage Access Framework on Android Q+
  • Optimized using a recycled list view (makes Instantiate calls sparingly)

NOTE: Universal Windows Platform (UWP) and WebGL platforms aren't supported!

INSTALLATION

There are 5 ways to install this plugin:

  • import SimpleFileBrowser.unitypackage via Assets-Import Package
  • clone/download this repository and move the Plugins folder to your Unity project's Assets folder
  • import it from Asset Store
  • (via Package Manager) add the following line to Packages/manifest.json:
    • "com.yasirkula.simplefilebrowser": "https://github.com/yasirkula/UnitySimpleFileBrowser.git",
  • (via OpenUPM) after installing openupm-cli, run the following command:
    • openupm add com.yasirkula.simplefilebrowser

FAQ

  • File browser doesn't show any files on Mac when sandboxing is enabled

This is a known issue but I can't give an ETA for a solution at the moment: #66

  • File browser doesn't show any files on Android 10+

File browser uses Storage Access Framework on these Android versions and users must first click the Browse... button in the quick links section.

  • File browser doesn't show any files on Oculus Quest

Please see: #87 and #89

  • File browser doesn't show any files on Unity 2021.3.x

Please see: #70

  • New Input System isn't supported on Unity 2019.2.5 or earlier

Add ENABLE_INPUT_SYSTEM compiler directive to Player Settings/Scripting Define Symbols (these symbols are platform specific, so if you change the active platform later, you'll have to add the compiler directive again).

  • "Unity.InputSystem" assembly can't be resolved on Unity 2018.4 or earlier

Remove Unity.InputSystem assembly from SimpleFileBrowser.Runtime Assembly Definition File's Assembly Definition References list.

  • Android build fails, it says "error: attribute android:requestLegacyExternalStorage not found" in Console

android:requestLegacyExternalStorage attribute in AndroidManifest.xml grants full access to device's storage on Android 10 but requires you to update your Android SDK to at least SDK 29. If this isn't possible for you, you should open SimpleFileBrowser.aar with WinRAR or 7-Zip and then remove the <application ... /> tag from AndroidManifest.xml.

  • Can't show the file browser on Android, it says "java.lang.ClassNotFoundException: com.yasirkula.unity.FileBrowserPermissionReceiver" in Logcat

If you are sure that your plugin is up-to-date, then enable Custom Proguard File option from Player Settings and add the following line to that file: -keep class com.yasirkula.unity.* { *; }

  • RequestPermission returns Permission.Denied on Android

Declare the WRITE_EXTERNAL_STORAGE permission manually in your Plugins/Android/AndroidManifest.xml file with the tools:node="replace" attribute as follows: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace"/> (you'll need to add the xmlns:tools="http://schemas.android.com/tools" attribute to the <manifest ...> element).

HOW TO

NOTE: On Android Q (10) or later, it is impossible to work with File APIs. On these devices, SimpleFileBrowser uses Storage Access Framework (SAF) to browse the files. However, paths returned by SAF are not File API compatible. To simulate the behaviour of the File API on all devices (including SAF), you can check out the FileBrowserHelpers functions. For reference, here is an example SAF path: content://com.android.externalstorage.documents/tree/primary%3A/document/primary%3APictures

First, add using SimpleFileBrowser; to your script.

The file browser can be shown either as a save dialog or a load dialog. In load mode, the returned path(s) always lead to existing files or folders. In save mode, the returned path(s) can point to non-existing files, as well. You can use the following functions to show the file browser:

public static bool ShowSaveDialog( OnSuccess onSuccess, OnCancel onCancel, PickMode pickMode, bool allowMultiSelection = false, string initialPath = null, string initialFilename = null, string title = "Save", string saveButtonText = "Save" );
public static bool ShowLoadDialog( OnSuccess onSuccess, OnCancel onCancel, PickMode pickMode, bool allowMultiSelection = false, string initialPath = null, string initialFilename = null, string title = "Load", string loadButtonText = "Select" );

public delegate void OnSuccess( string[] paths );
public delegate void OnCancel();

There can only be one dialog active at a time. These functions will return true if the dialog is shown successfully (if no other dialog is active), false otherwise. You can query the FileBrowser.IsOpen property to see if there is an active dialog at the moment.

If user presses the Cancel button, onCancel callback is called. Otherwise, onSuccess callback is called with the paths of the selected files/folders as parameter. pickMode can be Files, Folders or FilesAndFolders. Setting allowMultiSelection to true will allow picking multiple files/folders.

There are also coroutine variants of these functions that will yield while the dialog is active:

public static IEnumerator WaitForSaveDialog( PickMode pickMode, bool allowMultiSelection = false, string initialPath = null, string initialFilename = null, string title = "Save", string saveButtonText = "Save" );									 
public static IEnumerator WaitForLoadDialog( PickMode pickMode, bool allowMultiSelection = false, string initialPath = null, string initialFilename = null, string title = "Load", string loadButtonText = "Select" );

After the dialog is closed, you can check the FileBrowser.Success property to see whether the user has selected some files/folders or cancelled the operation and if FileBrowser.Success is set to true, you can use the FileBrowser.Result property to get the paths of the selected files/folders.

You can force close an open dialog using the following function:

public static void HideDialog( bool invokeCancelCallback = false );

If there is an open dialog and the invokeCancelCallback parameter is set to true, the onCancel callback of the dialog will be invoked. This function can also be used to initialize the file browser ahead of time, which in turn will reduce the lag when you first open a dialog.

To add a quick link to the browser, you can use the following function (to clear all quick links, use ClearQuickLinks()):

public static bool AddQuickLink( string name, string path, Sprite icon = null );

When icon parameter is left as null, the quick link will have a folder icon.

By default, the file browser doesn't show files with .lnk or .tmp extensions. You can extend this list or remove this restriction altogether using the following function:

public static void SetExcludedExtensions( params string[] excludedExtensions );

Lastly, you can use the following functions to set the file filters (filters should include the period, e.g. ".jpg" instead of "jpg"):

public static void SetFilters( bool showAllFilesFilter, IEnumerable<string> filters );
public static void SetFilters( bool showAllFilesFilter, params string[] filters );
public static void SetFilters( bool showAllFilesFilter, IEnumerable<FileBrowser.Filter> filters );
public static void SetFilters( bool showAllFilesFilter, params FileBrowser.Filter[] filters );

When showAllFilesFilter is set to true, a filter by the name "All Files (.*)" will appear that will show all the files when selected. To select a default filter, use the following function:

public static bool SetDefaultFilter( string defaultFilter );

You can programmatically filter the files/folders displayed in the file browser via the DisplayedEntriesFilter event:

FileBrowser.DisplayedEntriesFilter += ( entry ) =>
{
	if( !entry.IsDirectory )
		return true; // Don't filter files

	return entry.Name.StartsWith( "Save" ); // Show only the directories whose name start with "Save"
};

You can set whether or not hidden files should be shown in the file browser via FileBrowser.ShowHiddenFiles (has no effect when Storage Access Framework is used on Android 10+). This value can also be changed from the "Show hidden files" toggle in the user interface. To change the visibility of that toggle, you can use FileBrowser.DisplayHiddenFilesToggle. Note that this toggle is always hidden on Android 10+ when Storage Access Framework is used or on mobile devices when device is held in portrait orientation.

To open files or directories in the file browser with a single click (instead of double clicking), you can set FileBrowser.SingleClickMode to true.

File browser refreshes the list of drives at a regular interval to detect the insertion/removal of USB drives. This interval can be changed via FileBrowser.DrivesRefreshInterval. If its value is less than 0, list of drives won't be refreshed. By default, this value is 5 seconds on standalone platforms and -1 on mobile platforms.

In file saving mode, if the user selects one or more existing files, the file browser will show a file overwrite dialog. To disable this behaviour, you can set FileBrowser.ShowFileOverwriteDialog to false.

While saving files/folders or loading folders, file browser can check if the user has write access to the destination folder(s) to ensure that any file operations inside those folder(s) will work without any issues. To do that, file browser attempts to create dummy files inside those folder(s) and if it fails, an error dialog is displayed to the user. This feature is disabled by default because some folders may have write access but not delete access, in which case the created dummy file will remain in the destination folder(s). To enable this feature, you can set FileBrowser.CheckWriteAccessToDestinationDirectory to true.

File browser comes bundled with two premade skins in the Skins directory: LightSkin and DarkSkin. New UISkins can be created via Assets-Create-yasirkula-SimpleFileBrowser-UI Skin. A UISkin can be assigned to the file browser in two ways:

  • By changing SimpleFileBrowserCanvas prefab's Skin field
  • By changing the value of FileBrowser.Skin property from a C# script

On Android, file browser requires external storage access to function properly. You can use the following function to check if we have runtime permission to access the external storage:

public static FileBrowser.Permission CheckPermission();

FileBrowser.Permission is an enum that can take 3 values:

  • Granted: we have the permission to access the external storage
  • ShouldAsk: we don't have permission yet, but we can ask the user for permission via RequestPermission function (see below). As long as the user doesn't select "Don't ask again" while denying the permission, ShouldAsk is returned
  • Denied: we don't have permission and we can't ask the user for permission. In this case, user has to give the permission from Settings. This happens when user selects "Don't ask again" while denying the permission or when user is not allowed to give that permission (parental controls etc.)

To request permission to access the external storage, use the following function:

public static FileBrowser.Permission RequestPermission();

Note that FileBrowser automatically calls RequestPermission before opening a dialog. If you want, you can turn this feature off by setting FileBrowser.AskPermissions to false.

The following file manipulation functions work on all platforms (including Storage Access Framework (SAF) on Android 10+). These functions should be called with the paths returned by the FileBrowser functions only:

public static bool FileBrowserHelpers.FileExists( string path );
public static bool FileBrowserHelpers.DirectoryExists( string path );
public static bool FileBrowserHelpers.IsDirectory( string path );
public static bool FileBrowserHelpers.IsPathDescendantOfAnother( string path, string parentFolderPath );
public static string FileBrowserHelpers.GetDirectoryName( string path );
public static FileSystemEntry[] FileBrowserHelpers.GetEntriesInDirectory( string path, bool extractOnlyLastSuffixFromExtensions ); // Returns all files and folders in a directory. If you want "File.tar.gz"s extension to be extracted as ".tar.gz" instead of ".gz", set 'extractOnlyLastSuffixFromExtensions' to false
public static string FileBrowserHelpers.CreateFileInDirectory( string directoryPath, string filename ); // Returns the created file's path
public static string FileBrowserHelpers.CreateFolderInDirectory( string directoryPath, string folderName ); // Returns the created folder's path
public static void FileBrowserHelpers.WriteBytesToFile( string targetPath, byte[] bytes );
public static void FileBrowserHelpers.WriteTextToFile( string targetPath, string text );
public static void FileBrowserHelpers.AppendBytesToFile( string targetPath, byte[] bytes );
public static void FileBrowserHelpers.AppendTextToFile( string targetPath, string text );
public static byte[] FileBrowserHelpers.ReadBytesFromFile( string sourcePath );
public static string FileBrowserHelpers.ReadTextFromFile( string sourcePath );
public static void FileBrowserHelpers.CopyFile( string sourcePath, string destinationPath );
public static void FileBrowserHelpers.CopyDirectory( string sourcePath, string destinationPath );
public static void FileBrowserHelpers.MoveFile( string sourcePath, string destinationPath );
public static void FileBrowserHelpers.MoveDirectory( string sourcePath, string destinationPath );
public static string FileBrowserHelpers.RenameFile( string path, string newName ); // Returns the new path of the file
public static string FileBrowserHelpers.RenameDirectory( string path, string newName ); // Returns the new path of the directory
public static void FileBrowserHelpers.DeleteFile( string path );
public static void FileBrowserHelpers.DeleteDirectory( string path );
public static string FileBrowserHelpers.GetFilename( string path );
public static long FileBrowserHelpers.GetFilesize( string path );
public static DateTime FileBrowserHelpers.GetLastModifiedDate( string path );

EXAMPLE CODE

using UnityEngine;
using System.Collections;
using System.IO;
using SimpleFileBrowser;

public class FileBrowserTest : MonoBehaviour
{
	// Warning: paths returned by FileBrowser dialogs do not contain a trailing '\' character
	// Warning: FileBrowser can only show 1 dialog at a time

	void Start()
	{
		// Set filters (optional)
		// It is sufficient to set the filters just once (instead of each time before showing the file browser dialog), 
		// if all the dialogs will be using the same filters
		FileBrowser.SetFilters( true, new FileBrowser.Filter( "Images", ".jpg", ".png" ), new FileBrowser.Filter( "Text Files", ".txt", ".pdf" ) );

		// Set default filter that is selected when the dialog is shown (optional)
		// Returns true if the default filter is set successfully
		// In this case, set Images filter as the default filter
		FileBrowser.SetDefaultFilter( ".jpg" );

		// Set excluded file extensions (optional) (by default, .lnk and .tmp extensions are excluded)
		// Note that when you use this function, .lnk and .tmp extensions will no longer be
		// excluded unless you explicitly add them as parameters to the function
		FileBrowser.SetExcludedExtensions( ".lnk", ".tmp", ".zip", ".rar", ".exe" );

		// Add a new quick link to the browser (optional) (returns true if quick link is added successfully)
		// It is sufficient to add a quick link just once
		// Name: Users
		// Path: C:\Users
		// Icon: default (folder icon)
		FileBrowser.AddQuickLink( "Users", "C:\\Users", null );
		
		// !!! Uncomment any of the examples below to show the file browser !!!

		// Example 1: Show a save file dialog using callback approach
		// onSuccess event: not registered (which means this dialog is pretty useless)
		// onCancel event: not registered
		// Save file/folder: file, Allow multiple selection: false
		// Initial path: "C:\", Initial filename: "Screenshot.png"
		// Title: "Save As", Submit button text: "Save"
		// FileBrowser.ShowSaveDialog( null, null, FileBrowser.PickMode.Files, false, "C:\\", "Screenshot.png", "Save As", "Save" );

		// Example 2: Show a select folder dialog using callback approach
		// onSuccess event: print the selected folder's path
		// onCancel event: print "Canceled"
		// Load file/folder: folder, Allow multiple selection: false
		// Initial path: default (Documents), Initial filename: empty
		// Title: "Select Folder", Submit button text: "Select"
		// FileBrowser.ShowLoadDialog( ( paths ) => { Debug.Log( "Selected: " + paths[0] ); },
		//						   () => { Debug.Log( "Canceled" ); },
		//						   FileBrowser.PickMode.Folders, false, null, null, "Select Folder", "Select" );

		// Example 3: Show a select file dialog using coroutine approach
		// StartCoroutine( ShowLoadDialogCoroutine() );
	}

	IEnumerator ShowLoadDialogCoroutine()
	{
		// Show a load file dialog and wait for a response from user
		// Load file/folder: file, Allow multiple selection: true
		// Initial path: default (Documents), Initial filename: empty
		// Title: "Load File", Submit button text: "Load"
		yield return FileBrowser.WaitForLoadDialog( FileBrowser.PickMode.Files, true, null, null, "Select Files", "Load" );

		// Dialog is closed
		// Print whether the user has selected some files or cancelled the operation (FileBrowser.Success)
		Debug.Log( FileBrowser.Success );

		if( FileBrowser.Success )
			OnFilesSelected( FileBrowser.Result ); // FileBrowser.Result is null, if FileBrowser.Success is false
	}
	
	void OnFilesSelected( string[] filePaths )
	{
		// Print paths of the selected files
		for( int i = 0; i < filePaths.Length; i++ )
			Debug.Log( filePaths[i] );

		// Get the file path of the first selected file
		string filePath = filePaths[0];

		// Read the bytes of the first file via FileBrowserHelpers
		// Contrary to File.ReadAllBytes, this function works on Android 10+, as well
		byte[] bytes = FileBrowserHelpers.ReadBytesFromFile( filePath );

		// Or, copy the first file to persistentDataPath
		string destinationPath = Path.Combine( Application.persistentDataPath, FileBrowserHelpers.GetFilename( filePath ) );
		FileBrowserHelpers.CopyFile( filePath, destinationPath );
	}
}

unitysimplefilebrowser's People

Contributors

bclausdorff avatar joeyteng avatar mingkyme avatar yasirkula avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unitysimplefilebrowser's Issues

Out of memory error when getting audio file result

Hello and thank you for the great tools!

I'm getting a random out of memory error from line 341 of FileBrowserHelpers.cs
return File.ReadAllBytes(sourcePath);

It appears it is called through me using if (FileBrowser.Success)

It happens randomly when loading audio files- file sizes from 1 megabyte to 50 megabytes will randomly get this error. The same audio file will randomly get the error if loaded in multiple times. Any idea on a direction for me to go to resolve this? Thank you for your time.

problem with vr

i'm having a little problem using this asset with oculus rift, the object SimpleFileBrowserItem in filesContainer does not response to my seted pointer, instead it responses to my main camera as a pointer (probably a problem with OnPointerEnter void, but i'm not sure)

File browser does not display files or folders in directories containing system files

The file browser does not display any files or folders when opening a directory containing a system file (such as pagefile.sys in C:\). This only seems to happen in the IL2CPP build version, rather than the Mono version (or the editor).

I made this fix in FileBrowserHelpers.GetEntriesInDirectory:

try
{
    FileSystemInfo[] items = new DirectoryInfo(path).GetFileSystemInfos();
    var entries = new List<FileSystemEntry>();

    foreach (FileSystemInfo item in items)
    {
        try
        {
            if (!item.Attributes.HasFlag(FileAttributes.System))
                entries.Add(new FileSystemEntry(item));
        }
        catch (System.Exception e) {
            Debug.LogException(e);
        }
    }

    return entries.ToArray();
}
catch (System.Exception e)
{
    Debug.LogException(e);
    return null;
}

What do you think?

Making a confirmation panel for save file override.

Does the current package handle save file override confirmation? I see that the prefab has a delete confirmation panel, it would be nice to have a save file override confirmation panel too. Currently it's hard to check before saving since I can only get file paths when OnSuccess happens.

Duplicate error on build

Description of the bug

We have updated to version 1.4.7 but, for some reason, we are getting an error saying we have duplicate classes on "com.yarsikula.unity.FileBrowserPermissionReceiver" and "com.yarsikula.unity.FileBrowserPermissionFragment" found in modules SimpleFileBrowser.jar and Classes.jar.
Is there a way to fix this?

  • Unity version: 2019.4.15

Change aspect

Is possible to change the aspect of the file picker? Like increase size to make it more readable on little screens

Audio Not Played on Android

first of all thank you for this great plugin.
i have a problem and that is i want to pick a mp3 file from my local storage(from device) and then using audiosource i want to play it.
i have done this using this script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.UI;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using NAudio;
using NAudio.Wave;
using UnityEngine.Networking;
using SimpleFileBrowser;
public class ReadMp3 : MonoBehaviour
{
private AudioSource audioSource;
public Text pathText;

private void Start()
{
    audioSource = GetComponent<AudioSource>();
}
public void ReadMp3Sounds()
{
    FileBrowser.SetFilters(false, new FileBrowser.Filter("Sounds", ".mp3"));
    FileBrowser.SetDefaultFilter(".mp3");
    StartCoroutine(ShowLoadDialogCoroutine());
}
IEnumerator ShowLoadDialogCoroutine()
{
    yield return FileBrowser.WaitForLoadDialog(false, null, "Select Sound", "Select");
    pathText.text = FileBrowser.Result;
    if (FileBrowser.Success)
    {
        byte[] SoundFile = FileBrowserHelpers.ReadBytesFromFile(FileBrowser.Result);
        yield return SoundFile;
        audioSource.clip = NAudioPlayer.FromMp3Data(SoundFile);
        audioSource.Play();
    }
}

}

in this script i used NAudio.dll file to accomplished it.
now my problem is that i successfully play audio song from my computer but when i build it for android all things worked properly(i could select mp3 from my android device),but the song was didn't played.
can you please tell me how can i do that for android or i made any mistake or something.

Access Denied when using folder ?

Hey. This is a fantastic plugin. Thanks a lot for making it.

I've been trying to get this to work all day. I get an access error every time i try to load a folder. Apologies in advance, it's probably super simple.

When I use

This method:
yield return FileBrowser.WaitForLoadDialog( FileBrowser.PickMode.FilesAndFolders, true, null, null, "Load Files and Folders", "Load" );

I get the following error when opening a folder:

UnauthorizedAccessException: Access to the path 'and insert path here' is denied;

I've tried using the folders only option, but it yields the same result.

I then tried using your other method

FileBrowser.ShowLoadDialog( ( paths ) => { Debug.Log( "Selected: " + paths[0] ); },
								   () => { Debug.Log( "Canceled" ); },
								   FileBrowser.PickMode.Folders, false, null, null, "Select Folder", "Select" );

But my issue here is that I can't figure out how to read paths[0] afterwards. I tried using OnSuccess but I have no idea how to get the value out of that either.

Hope you can help. An example would be great. Thanks in advance.

Exception - UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.yasirkula.unity.FileBrowserPermissionReceiver

I am getting the above error when using the example code provided. The exception is hit when running the yield return FileBrowser.WaitForLoadDialog(false, true, null, "Load File", "Load");

It is worth noting that the same works when I test on desktop, but when I build this and run on my Android phone (Note 10), it hits this error.

Can you please advise on what I could do to overcome this issue?

NullReferenceException on Unity 2019.4.1

Description of the bug

NullReferenceException: Object reference not set to an instance of an object
SimpleFileBrowser.RecycledListView.UpdateList () (at Assets/Plugins/SimpleFileBrowser/Scripts/SimpleRecycledListView/RecycledListView.cs:55)
SimpleFileBrowser.FileBrowser.RefreshFiles (System.Boolean pathChanged) (at Assets/Plugins/SimpleFileBrowser/Scripts/FileBrowser.cs:1420)
SimpleFileBrowser.FileBrowser.OnShowHiddenFilesToggleChanged () (at Assets/Plugins/SimpleFileBrowser/Scripts/FileBrowser.cs:1071)
UnityEngine.Events.InvokableCall.Invoke () (at <4eca0aa85b9643a199169bb7e91fc8d3>:0)
UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) (at <4eca0aa85b9643a199169bb7e91fc8d3>:0)
UnityEngine.UI.Toggle.Rebuild (UnityEngine.UI.CanvasUpdate executing) (at D:/unity/2019.4.0f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Toggle.cs:130)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at D:/unity/2019.4.0f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/CanvasUpdateRegistry.cs:177)
UnityEngine.UI.ScrollRect:LateUpdate() (at D:/unity/2019.4.0f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/ScrollRect.cs:805)

Reproduction steps

FileBrowser.ShowLoadDialog((paths => {
                //todo
}), () => {
                //todo
});

Platform specs

Please provide the following info if this is a Unity 3D repository.

  • Unity version: 2019.4.1
  • Platform: Windows
  • How did you download the plugin: Asset Store version 1.3.6

Additional info

Please check Logcat (Android) or Xcode console (iOS) for any meaningful error messages and include them here.

Can't get the file path on android

The file path turns out to be empty when I select a file. The browser can access external directory's contents fine. I see all the files. But when I select them the path is empty. The same code works fine on Windows.
SimpleFileBrowser.FileBrowser.ShowLoadDialog( (path) => { uupdate(path); }, null, false, null, "Select File", "Select" );

Filepath working on Windows but failing on Android

The FileBrowser was working fine until a few days, but since a few commits the android filepath seems to be wrong:
content://com.android.externalstorage.documents/tree/primary%3ADCIM/document/primary%3ADCIM%2FScreenshots%2Fphoto.jpg

When I test in Unity 2019 and upload files via Windows everything seems to be fine. The path comes from the ShowLoadDialogCoroutine directly. It doubles the path for some reason. I did not change anything in the filebrowser i believe. Anyone had some similar issues?

How to change color?

The file browser is great and works functionally? But some people want a dark background instead of white.

image

Any idea how we can modify the white to gray?

Can using for webgl?

Hello,
Thank you for this support, this is pretty, but this can support browser file on PC for Webgl built.
Edit: I'll try and can not T.T

Not working perfectly in iOS

Description of the bug

In iOS, files are not showing as expected. Some folders are showing, but not regular folders like photos or users folder.

Also, it's possible to create a folder from the runtime, but it's not found in the iPhone default file browser.

Reproduction steps
Used the following code in a coroutine -

  FileBrowser.SetFilters(true, new FileBrowser.Filter("Image", ".jpg", ".png", "public.image"), new FileBrowser.Filter("PDF", ".pdf"));
  FileBrowser.SetDefaultFilter(".png");

  yield return FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.Files, false);

  if (FileBrowser.Success)
  {
      string filePath = FileBrowser.Result[0];
      Debug.Log("File Path - " + filePath);
      //my codes here
  }

Result-
issue_ios
issue_ios2

Platform specs

  • Unity version: 2019.4.7f1
  • Platform: iOS
  • Device: IPhone 12 Pro Max ver. 14.5
  • Target Min iOS Version: 11
  • How did you download the plugin: GitHub

simple file browser for vr systems

hi, is there any way to use this file browser for vr systems.
I tried some solutions,
-using a pointer instead of a mouse.
-changing the canvas render mode "overlay to wordspace."
in generally some of my applications work well, but "SimpleFileBrowserWindow" under the "SimpleFileBrowserCanvas" often cause problems.

Images Thumbnails

How to display images thumbnails instead of nice icons that exist now so the user can see what he is choosing from?

Browser is letting clicks through and interacting with background UI

Description of the bug

Browser is letting clicks through its frame as long as there is no UI element (like buttons, or the file-list-element). It happens that you accidentally click on buttons behind the browser.

Reproduction steps

Create a scene with a canvas. Add two buttons (one to open browser, one to check if it gets clicked through the browser).
Add sample script from github and change the start function to a public function to open the browser on click.

Platform specs

  • Unity version: 2019.4.22f1
  • Platform: Android
  • Device: Samsung Galaxy S10e on Android 11 & Unity Play Mode
  • How did you download the plugin: Unity AssetStore

UWP compatibility

At the moment I am trying to build a project including the file browser to UWP, but I get errors. I can not use Environment.SpecialFolder (and some more functionalities in this class) which seems to be not included in UWP. Maybe there is a quick fix. For today I will just try to include the UWP file browser. Of course it would be cool, if this file browser could do this too.

Select file or folder

Is it possible to select either a file or a folder using the ShowLoadDialog? if i folder mode to true then I can't select a file even if I provide filters

don´t return nothing on load button clicked

using the base code i can't pass from "yield return FileBrowser.WaitForLoadDialog( false, true, null, "Load File", "Load" );", not even the debug return a message, i'm using the version in the asset store

Reopening FileBrowser in onSuccess or onCancel

When calling ShowLoadDialog or ShowSaveDialog inside one of the callback functions to open a new dialog after the first one was closed, the OnOperationSuccessful or OnOperationCanceled method immediately sets the onSucess and onCancel members to null:

	private void OnOperationCanceled( bool invokeCancelCallback )
	{
		Success = false;
		Result = null;

		Hide();

		if( invokeCancelCallback && onCancel != null )
			onCancel(); // **Open new dialog here**

		onSuccess = null; // **It breaks because the callbacks are set to null**
		onCancel = null;
	}

Removing the last two lines of the method would allow "chaining" of dialogs.

Add an 'any supported format' filter

We have used this with great success in our Global Game Jam 2017 game Eye Can't Hear.

One question/feature request though: We want players to be able to add any supported audio file. As such, we'd like a filter to allow the player to select any file having one of the .mp3, .wav, .flac, .aiff, .ogg extensions.

An 'any supported format' filter would be greatly appreciated.

Suggestion: accept full paths in filename input field

In the native Windows file dialog, if you type a full path in the filename input field instead of just a filename, it will follow the full path and open the file. But in the current version of SimpleFileBrowser, if you do this, the field just turns red and nothing happens. I think this feature would be very useful, because it allows the user to copy a file's full path on Windows Explorer (Shift+Right Click, Copy as path), paste it directly on SimpleFileBrowser, and press Enter to open it right away.

Example of expected behavior:

  • Open Load dialog at some random directory, e.g. C:\, with PickMode.Files.
  • Write "C:\dir1\dir2\file.txt" (with or without quotes) on the filename input field and press Enter or click Select.
  • The file is selected and onSuccess is invoked as usual.

The native Windows dialog goes even further, and if you write a dir path, it changes the current dir to that dir, and it even accepts relative paths. But I imagine that's more effort. There's also the question of what the behavior should be for PickMode.Folders, and FilesAndFolders. I would already be very thankful just for absolute paths in the Load dialog for .Files.

Using a custom canvas for FileBrowser on Android 10

I am trying to figure out if I can use a custom canvas instead of having to call ShowLoadDialog on Android 10. I have been developing an application for quite some time now and have been using this great browser on other platforms. In my app I set up a custom canvans to place the file browser window in a specific area on the screen. To open the file browser canvas I used to just activate and deactivate the Canvas GameObject during runtime and this still works on Windows Platforms. On Android 10 however, if i try to use my custom canvas, when I activate the gameobject I get no file listings and the quick links is blank. I tryid a simple test on Android by calling ShowLoadDialog instead of my custom canvas and the browser does give me the file listings and quick links shows primary drive. Is there a way to get the file listings to show up on Android 10 without having to call ShowLoadDialog as it works on Windows?

File manager slows down.

Hello! I have a little problem: on some computers file manager slows down and opens directories for a long time (even on computers with ssd), but on most others it works good(even on computers with hard drive)(windows). What could be the problem? Thank you in advance.

Android can't view storage

I'm not sure whether the culprit is my phone or a bug in SimpleFileBrowser but I suspect the Android. I need help to be able to use the asset.

Android 9. At the start of the app I use CheckPermissions() which returns "Denied". I then use RequestPermissions() and re-check. It again says "Denied". Android app permissions says no permissions are requested.
The Load window left panel shows "Primary Drive" with the right one empty. Also tapping/double tapping "Primary Drive" does nothing. Still, an "up" button is present that when tapped twice it shows in the right panel: a numbered folder, "emulated", "enc_emulated" and "self". All are empty.

Android 10 Android app permissions says no permissions are allowed and no permissions are denied and CheckPermissions() returns "Denied" and after RequestPermissions() it's still "Denied". But after that, the Load window requested access to "Downloads" then to other locations as I browsed. These permissions are apparently saved from session to session but a new session start still shows "Denied".

How can I make it work on Android 9?

InputSystem does not exist in the namespace

Description of the bug

Filebrowser.cs(10,19): error CS0234: the type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine'.

Also happens in FileBrowserDeleteConfirmationPanel and FileBrowserRenamedItem.

Reproduction steps

I just downloaded and imported SimpleFileBrowser into my project. And it is generating these errors. I am using the latest InputSystem since I need to using some keypresses as input to my unity project.

Platform specs

Please provide the following info if this is a Unity 3D repository.

  • Unity version: 20194.12f1
  • Platform: Mac OS BigSur
  • Device: NA Macbook Pro 2016 with touchbar
  • How did you download the plugin: Package Manager

Additional info

NA

Thank you and have a nice day!

标题栏的bug

如果标题栏的路径很长,启动时设置默认路径,那么窗口显示时会隐藏后面的路径,这种体验感并不友好,我修改了下脚本解决了这个问题
pathInputField.text = m_currentPath;
pathInputField.ActivateInputField();
pathInputField.Select();
StartCoroutine(MoveTextEnd_NextFrame());

IEnumerator MoveTextEnd_NextFrame()
{
yield return new WaitForEndOfFrame() ;
pathInputField.MoveTextEnd(false);

    }

Select multiple files

First, thanks for this awesome Asset !

Would it require a lot of work to allow selecting multiple files in a folder and obtain list of paths ?

[Help wanted]

How to add default name when open dialog save file ?
Ths so much

Platform specs

  • Unity version: e.g. 2019.3.9f1
  • Platform: Windows 10
    .

Issue with Unity 2017.3.0

Hi,

I love your code and I used it for 5.6 but when I upgraded unity to the latest one, when I use your plugins it does not show all files in a folder. Because of that, the plugin is unusable.

All I can select is folder ONLY.

OS: Android 4.4.2
CPU: RK3288
I paste the sample codes, build the apk, and install it to my system.
Dialog shows, I can switch to every folder I want, but I can't see and files.
Is that a bug?

QuickLinks initialised before permission grant on Android

Hello, first of all I love your asset and thank you for opensourcing it.
I think I discovered a little bug.

On Android, you need to ask for the READ_EXTERNAL_STORAGE permission to access, for example, the content of an external SD card. But, in FileBrowser.cs L.492, you call InitializeQuickLinks in the Awake function, before the user is asked for the permission to read files. Which means that the external SD card you may have, won't appear in the QuickLinks of the SimpleFileBrowserCanvas, even if the permission to access it has been given afterwards.

The bug is not blocking, since on all following app launches, if you don't revoke the permission of the app, you won't ever see it anymore. But it still would be better if it also worked the first time.

After loading a file Unity complains about two EventSystems in the scene

Thanks for your great asset!!

Following your code example on github, I got it working instantly. Only one question. After loading a file, Unity complains that there are two EventSystems in the scene.

How can I get rid of it? I have a Canvas and a UI and already an EventSytem in place.

Simple File Browser - Click & Head Tracking

Description of the bug

Dear Sir,
I am using your "simple file browser" for my VR project. Actually, it's working well but there is something that I did not get it.
I can select the files from the list but i cannot click them. I can interact with all the buttons in my interface, but I cannot click the files in the file list. In addition, my oculus rift headset acting like a pointer when I'm on the file list panel. While I moving my head from up to down or vice versa I can select the files like my pointers.

Reproduction steps

-changing the canvas render mode "overlay to wordspace.

  • using oculus rift SDK with VRTK

Platform specs

  • Unity version: * 2019.3.10*
  • Platform: Windows
  • How did you download the plugin: * Asset Store*

Screenshot
ss

File & folder name is incorrect on Korean

Description of the bug
Screen Shot 2021-01-19 at 12 43 40 AM
Screen Shot 2021-01-19 at 12 43 50 AM

"부산시" <= That's folder name.

Platform specs

  • Unity version: 2019.04.18f
  • Platform: MAC
  • Device: Mac OS
  • How did you download the plugin: Asset Store

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.