You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Changed folderMode parameter to pickMode that supports picking files and folders simultaneously
- Added optional initialFilename parameter to prefill the filename input field
- Files and folders are now sorted by their names (they weren't automatically sorted on some platforms)
- Made AllFilesFilterText, FoldersFilterText and PickFolderQuickLinkText properties public static so that these labels can be localized or customized
- Write External Storage permission is now added automatically on Android (no manual setup is needed)
Copy file name to clipboardExpand all lines: .github/README.md
+20-19Lines changed: 20 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@
20
20
- Supports runtime permissions on Android M+ and *Storage Access Framework* on Android Q+
21
21
- Optimized using a recycled list view (makes *Instantiate* calls sparingly)
22
22
23
-
**NOTE:** Universal Windows Platform (UWP) is not supported!
23
+
**NOTE:***Universal Windows Platform (UWP)* and *WebGL* platforms aren't supported!
24
24
25
25
## INSTALLATION
26
26
@@ -40,41 +40,39 @@ There are 5 ways to install this plugin:
40
40
41
41
If your project uses ProGuard, try adding the following line to ProGuard filters: `-keep class com.yasirkula.unity.* { *; }`
42
42
43
-
-**File browser doesn't show any files on Android**
43
+
-**File browser doesn't show any files on Android 10+**
44
44
45
-
Make sure that you've set the **Write Permission** to **External (SDCard)** in *Player Settings*. On Android 10+, file browser uses *Storage Access Framework* and users must click the *Pick Folder* button first.
45
+
File browser uses *Storage Access Framework*on these Android versions and users must first click the *Pick Folder* button in the quick links section
46
46
47
-
-**RequestPermission returns Permission.Denied on Android even though I've set "Write Permission" to "External (SDCard)"**
47
+
-**RequestPermission returns Permission.Denied on Android**
48
48
49
49
Declare the `WRITE_EXTERNAL_STORAGE` permission manually in your [**Plugins/Android/AndroidManifest.xml** file](https://answers.unity.com/questions/982710/where-is-the-manifest-file-in-unity.html) 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).
50
50
51
51
## HOW TO
52
52
53
-
*for Android*: set **Write Permission** to **External (SDCard)** in **Player Settings**
54
-
55
53
**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`
56
54
57
55
First, add `using SimpleFileBrowser;` to your script.
58
56
59
57
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:
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.
70
68
71
-
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. When **folderMode**is set to *true*, the file browser will show only folders and the user will pick folders instead of files. Setting **allowMultiSelection** to *true* will allow picking multiple files/folders.
69
+
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.
72
70
73
71
There are also coroutine variants of these functions that will yield while the dialog is active:
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.
@@ -205,17 +203,19 @@ public class FileBrowserTest : MonoBehaviour
205
203
// onSuccess event: not registered (which means this dialog is pretty useless)
206
204
// onCancel event: not registered
207
205
// Save file/folder: file, Allow multiple selection: false
This plugin helps you show save/load dialogs during gameplay with its uGUI based file browser.
8
8
9
-
2. HOW TO
10
-
for Android: set Write Permission to External (SDCard) in Player Settings
11
9
10
+
2. HOW TO
12
11
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.
13
12
14
-
3. SCRIPTING API
13
+
14
+
3. FAQ
15
+
- Can't show the file browser on Android, it says "java.lang.ClassNotFoundException: com.yasirkula.unity.FileBrowserPermissionReceiver" in Logcat
16
+
If your project uses ProGuard, try adding the following line to ProGuard filters: -keep class com.yasirkula.unity.* { *; }
17
+
18
+
- File browser doesn't show any files on Android 10+
19
+
File browser uses Storage Access Framework on these Android versions and users must first click the "Pick Folder" button in the quick links section
20
+
21
+
- RequestPermission returns Permission.Denied on Android
22
+
Declare the WRITE_EXTERNAL_STORAGE permission manually in your Plugins/Android/AndroidManifest.xml file as follows: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace"/>
23
+
You'll need to add the following attribute to the '<manifest ...>' element: xmlns:tools="http://schemas.android.com/tools"
24
+
25
+
26
+
4. SCRIPTING API
15
27
Please see the online documentation for a more in-depth documentation of the Scripting API: https://github.com/yasirkula/UnitySimpleFileBrowser
16
28
17
29
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
@@ -20,16 +32,17 @@ NOTE: On Android Q (10) or later, it is impossible to work with File APIs. On th
0 commit comments