Skip to content

Commit 4b2594c

Browse files
committed
- Added skins! Create new skins via "yasirkula-SimpleFileBrowser-UI Skin"
- Added CC0-licensed file icons for common file types - Files can now have alternating background colors - File browser remembers the most recently browsed folder even if the application is restarted
1 parent 039bbb7 commit 4b2594c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2025
-252
lines changed

.github/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- Draggable and resizable
1818
- Ability to choose folders instead of files
1919
- Supports selecting multiple files/folders
20+
- Can easily be reskinned
2021
- Supports runtime permissions on Android M+ and *Storage Access Framework* on Android Q+
2122
- Optimized using a recycled list view (makes *Instantiate* calls sparingly)
2223

@@ -133,6 +134,11 @@ To open files or directories in the file browser with a single click (instead of
133134

134135
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.
135136

137+
File browser comes bundled with two premade skins in the *Skins* directory: *LightSkin* and *DarkSkin*. New **UISkin**s can be created via `Assets-Create-yasirkula-SimpleFileBrowser-UI Skin`. A UISkin can be assigned to the file browser in two ways:
138+
139+
- By changing *SimpleFileBrowserCanvas* prefab's *Skin* field
140+
- By changing the value of `FileBrowser.Skin` property from a C# script
141+
136142
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:
137143

138144
```csharp

.github/screenshots/filebrowser.png

93.1 KB
Loading

Plugins/SimpleFileBrowser/Prefabs/SimpleFileBrowserItem.prefab

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ GameObject:
7373
- component: {fileID: 224447975432582502}
7474
- component: {fileID: 222113778025760416}
7575
- component: {fileID: 114807149938652920}
76+
- component: {fileID: 114942441918357790}
7677
m_Layer: 5
7778
m_Name: Icon
7879
m_TagString: Untagged
@@ -209,6 +210,20 @@ MonoBehaviour:
209210
m_FillAmount: 1
210211
m_FillClockwise: 1
211212
m_FillOrigin: 0
213+
--- !u!114 &114942441918357790
214+
MonoBehaviour:
215+
m_ObjectHideFlags: 1
216+
m_PrefabParentObject: {fileID: 0}
217+
m_PrefabInternal: {fileID: 100100000}
218+
m_GameObject: {fileID: 1268973638054374}
219+
m_Enabled: 1
220+
m_EditorHideFlags: 0
221+
m_Script: {fileID: 1573420865, guid: f70555f144d8491a825f0804e09c671c, type: 3}
222+
m_Name:
223+
m_EditorClassIdentifier:
224+
m_EffectColor: {r: 0, g: 0, b: 0, a: 0.1764706}
225+
m_EffectDistance: {x: 0.75, y: -0.75}
226+
m_UseGraphicAlpha: 1
212227
--- !u!222 &222000010857273394
213228
CanvasRenderer:
214229
m_ObjectHideFlags: 1
@@ -267,7 +282,7 @@ RectTransform:
267282
m_AnchorMin: {x: 0, y: 0}
268283
m_AnchorMax: {x: 1, y: 1}
269284
m_AnchoredPosition: {x: 19, y: 0}
270-
m_SizeDelta: {x: -38, y: -4}
285+
m_SizeDelta: {x: -38, y: 0}
271286
m_Pivot: {x: 0.5, y: 0.5}
272287
--- !u!224 &224000013952242090
273288
RectTransform:

Plugins/SimpleFileBrowser/Prefabs/SimpleFileBrowserQuickLink.prefab

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ GameObject:
5656
- component: {fileID: 224000012393993334}
5757
- component: {fileID: 222000012809932278}
5858
- component: {fileID: 114000013208375990}
59+
- component: {fileID: 114174331659558594}
5960
m_Layer: 5
6061
m_Name: Icon
6162
m_TagString: Untagged
@@ -165,6 +166,20 @@ MonoBehaviour:
165166
m_VerticalOverflow: 0
166167
m_LineSpacing: 1
167168
m_Text: Filename
169+
--- !u!114 &114174331659558594
170+
MonoBehaviour:
171+
m_ObjectHideFlags: 1
172+
m_PrefabParentObject: {fileID: 0}
173+
m_PrefabInternal: {fileID: 100100000}
174+
m_GameObject: {fileID: 1000013967986654}
175+
m_Enabled: 1
176+
m_EditorHideFlags: 0
177+
m_Script: {fileID: 1573420865, guid: f70555f144d8491a825f0804e09c671c, type: 3}
178+
m_Name:
179+
m_EditorClassIdentifier:
180+
m_EffectColor: {r: 0, g: 0, b: 0, a: 0.1764706}
181+
m_EffectDistance: {x: 0.75, y: -0.75}
182+
m_UseGraphicAlpha: 1
168183
--- !u!222 &222000010857273394
169184
CanvasRenderer:
170185
m_ObjectHideFlags: 1
@@ -217,7 +232,7 @@ RectTransform:
217232
m_AnchorMin: {x: 0, y: 0}
218233
m_AnchorMax: {x: 1, y: 1}
219234
m_AnchoredPosition: {x: 19, y: 0}
220-
m_SizeDelta: {x: -38, y: -4}
235+
m_SizeDelta: {x: -38, y: 0}
221236
m_Pivot: {x: 0.5, y: 0.5}
222237
--- !u!224 &224000013952242090
223238
RectTransform:

Plugins/SimpleFileBrowser/README.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ This plugin helps you show save/load dialogs during gameplay with its uGUI based
1010
### HOW TO
1111
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.
1212

13+
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:
14+
15+
- By changing SimpleFileBrowserCanvas prefab's Skin field
16+
- By changing the value of FileBrowser.Skin property from a C# script
17+
1318

1419
### NEW INPUT SYSTEM SUPPORT
1520
This plugin supports Unity's new Input System but it requires some manual modifications (if both the legacy and the new input systems are active at the same time, no changes are needed):
@@ -49,6 +54,9 @@ public enum PickMode { Files = 0, Folders = 1, FilesAndFolders = 2 };
4954
public delegate void OnSuccess( string[] paths );
5055
public delegate void OnCancel();
5156

57+
// Changing the dialog's skin
58+
public static UISkin Skin { get; set; }
59+
5260
// Showing dialog
5361
bool ShowSaveDialog( OnSuccess onSuccess, OnCancel onCancel, PickMode pickMode, bool allowMultiSelection = false, string initialPath = null, string initialFilename = null, string title = "Save", string saveButtonText = "Save" );
5462
bool ShowLoadDialog( OnSuccess onSuccess, OnCancel onCancel, PickMode pickMode, bool allowMultiSelection = false, string initialPath = null, string initialFilename = null, string title = "Load", string loadButtonText = "Select" );

Plugins/SimpleFileBrowser/Resources/SimpleFileBrowserCanvas.prefab

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,7 +1973,7 @@ MonoBehaviour:
19731973
m_Name:
19741974
m_EditorClassIdentifier:
19751975
m_Material: {fileID: 0}
1976-
m_Color: {r: 1, g: 1, b: 1, a: 1}
1976+
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
19771977
m_RaycastTarget: 1
19781978
m_OnCullStateChanged:
19791979
m_PersistentCalls:
@@ -2255,7 +2255,7 @@ MonoBehaviour:
22552255
m_TypeName: UnityEngine.UI.InputField+OnChangeEvent, UnityEngine.UI, Version=1.0.0.0,
22562256
Culture=neutral, PublicKeyToken=null
22572257
m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
2258-
m_CustomCaretColor: 0
2258+
m_CustomCaretColor: 1
22592259
m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412}
22602260
m_Text:
22612261
m_CaretBlinkRate: 0.85
@@ -2326,7 +2326,7 @@ MonoBehaviour:
23262326
m_TargetGraphic: {fileID: 114000010382772448}
23272327
m_HandleRect: {fileID: 224000013440901968}
23282328
m_Direction: 2
2329-
m_Value: 1
2329+
m_Value: 0
23302330
m_Size: 1
23312331
m_NumberOfSteps: 0
23322332
m_OnValueChanged:
@@ -2901,7 +2901,7 @@ MonoBehaviour:
29012901
m_Name:
29022902
m_EditorClassIdentifier:
29032903
m_Material: {fileID: 0}
2904-
m_Color: {r: 1, g: 1, b: 1, a: 1}
2904+
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
29052905
m_RaycastTarget: 1
29062906
m_OnCullStateChanged:
29072907
m_PersistentCalls:
@@ -3417,7 +3417,7 @@ MonoBehaviour:
34173417
m_Name:
34183418
m_EditorClassIdentifier:
34193419
m_Material: {fileID: 0}
3420-
m_Color: {r: 1, g: 1, b: 1, a: 1}
3420+
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
34213421
m_RaycastTarget: 1
34223422
m_OnCullStateChanged:
34233423
m_PersistentCalls:
@@ -3500,7 +3500,7 @@ MonoBehaviour:
35003500
m_TypeName: UnityEngine.UI.InputField+OnChangeEvent, UnityEngine.UI, Version=1.0.0.0,
35013501
Culture=neutral, PublicKeyToken=null
35023502
m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
3503-
m_CustomCaretColor: 0
3503+
m_CustomCaretColor: 1
35043504
m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412}
35053505
m_Text:
35063506
m_CaretBlinkRate: 0.85
@@ -3784,7 +3784,7 @@ MonoBehaviour:
37843784
m_TargetGraphic: {fileID: 114000011769758306}
37853785
m_HandleRect: {fileID: 224000011063755118}
37863786
m_Direction: 2
3787-
m_Value: 0
3787+
m_Value: 1
37883788
m_Size: 1
37893789
m_NumberOfSteps: 0
37903790
m_OnValueChanged:
@@ -3803,18 +3803,16 @@ MonoBehaviour:
38033803
m_Script: {fileID: 11500000, guid: f51dc09bf9e35804ba0f5e76c527025e, type: 3}
38043804
m_Name:
38053805
m_EditorClassIdentifier:
3806-
normalFileColor: {r: 1, g: 1, b: 1, a: 1}
3807-
hoveredFileColor: {r: 0.88235295, g: 0.88235295, b: 1, a: 1}
3808-
selectedFileColor: {r: 0, g: 0.5882353, b: 1, a: 1}
3809-
wrongFilenameColor: {r: 1, g: 0.39215687, b: 0.39215687, a: 1}
3806+
m_skin: {fileID: 11400000, guid: 758becaa4751c514ab3abd821b4078bb, type: 2}
38103807
minWidth: 380
38113808
minHeight: 300
38123809
narrowScreenWidth: 380
38133810
quickLinksMaxWidthPercentage: 0.4
38143811
sortFilesByName: 1
3815-
excludeExtensions:
3812+
excludedExtensions:
38163813
- .lnk
38173814
- .tmp
3815+
- .url
38183816
quickLinks:
38193817
- target: 5
38203818
name: Documents
@@ -3826,26 +3824,6 @@ MonoBehaviour:
38263824
contextMenuShowDeleteButton: 1
38273825
contextMenuShowRenameButton: 1
38283826
showResizeCursor: 1
3829-
folderIcon: {fileID: 21300000, guid: 05e18bb0a86cfdb4dbf887d382b69249, type: 3}
3830-
driveIcon: {fileID: 21300000, guid: c3f6bb04213791646b2e4824be1436dc, type: 3}
3831-
defaultIcon: {fileID: 21300000, guid: 372a6728b63455845bdad04ffc8a323b, type: 3}
3832-
filetypeIcons:
3833-
- extension: .txt
3834-
icon: {fileID: 21300000, guid: d9b30118e14d81742a606dac7cc44d7e, type: 3}
3835-
- extension: .doc
3836-
icon: {fileID: 21300000, guid: d9b30118e14d81742a606dac7cc44d7e, type: 3}
3837-
- extension: .docx
3838-
icon: {fileID: 21300000, guid: d9b30118e14d81742a606dac7cc44d7e, type: 3}
3839-
- extension: .jpg
3840-
icon: {fileID: 21300000, guid: d95a00b6cdb17884682cd580102f14e0, type: 3}
3841-
- extension: .jpeg
3842-
icon: {fileID: 21300000, guid: d95a00b6cdb17884682cd580102f14e0, type: 3}
3843-
- extension: .png
3844-
icon: {fileID: 21300000, guid: d95a00b6cdb17884682cd580102f14e0, type: 3}
3845-
multiSelectionToggleOffIcon: {fileID: 21300000, guid: d6beaeac8de2af749a48581db778df3e,
3846-
type: 3}
3847-
multiSelectionToggleOnIcon: {fileID: 21300000, guid: 30a2566f94f937b4998542121050e68b,
3848-
type: 3}
38493827
window: {fileID: 114000011184475620}
38503828
topViewNarrowScreen: {fileID: 224000012236837694}
38513829
middleView: {fileID: 224000012041644098}
@@ -3860,11 +3838,13 @@ MonoBehaviour:
38603838
backButton: {fileID: 114000010360865314}
38613839
forwardButton: {fileID: 114000012076811388}
38623840
upButton: {fileID: 114000013838333444}
3841+
moreOptionsButton: {fileID: 114144994822079520}
38633842
pathInputField: {fileID: 114000013413615576}
38643843
pathInputFieldSlotTop: {fileID: 224811477075121130}
38653844
pathInputFieldSlotBottom: {fileID: 224127867913948392}
38663845
searchInputField: {fileID: 114000010785476448}
38673846
quickLinksContainer: {fileID: 224000010383356806}
3847+
quickLinksScrollRect: {fileID: 114000013198154200}
38683848
filesContainer: {fileID: 224000012931849942}
38693849
filesScrollRect: {fileID: 114000011744356224}
38703850
listView: {fileID: 114985255881820402}
@@ -3876,6 +3856,9 @@ MonoBehaviour:
38763856
filterItemTemplate: {fileID: 114000013840550810}
38773857
showHiddenFilesToggle: {fileID: 114000011511084512}
38783858
submitButtonText: {fileID: 114000013382491478}
3859+
allButtons:
3860+
- {fileID: 114000014005904746}
3861+
- {fileID: 114000013207029700}
38793862
moreOptionsContextMenuPosition: {fileID: 224838098161518584}
38803863
renameItem: {fileID: 114205106981145908}
38813864
contextMenu: {fileID: 114581495326313396}
@@ -5419,7 +5402,7 @@ MonoBehaviour:
54195402
m_TypeName: UnityEngine.UI.InputField+OnChangeEvent, UnityEngine.UI, Version=1.0.0.0,
54205403
Culture=neutral, PublicKeyToken=null
54215404
m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
5422-
m_CustomCaretColor: 0
5405+
m_CustomCaretColor: 1
54235406
m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412}
54245407
m_Text:
54255408
m_CaretBlinkRate: 0.85
@@ -5909,9 +5892,20 @@ MonoBehaviour:
59095892
rectTransform: {fileID: 224387572643228028}
59105893
selectAllButton: {fileID: 114370003170116688}
59115894
deselectAllButton: {fileID: 114364461900096894}
5895+
createFolderButton: {fileID: 114346774628667646}
59125896
deleteButton: {fileID: 114128867067796106}
59135897
renameButton: {fileID: 114411366083395940}
59145898
selectAllButtonSeparator: {fileID: 1743655712281856}
5899+
allButtonTexts:
5900+
- {fileID: 114522847327260972}
5901+
- {fileID: 114565051423253148}
5902+
- {fileID: 114314828806938924}
5903+
- {fileID: 114302359538897432}
5904+
- {fileID: 114353583898203612}
5905+
allButtonSeparators:
5906+
- {fileID: 114076502751505788}
5907+
- {fileID: 114041711672230222}
5908+
- {fileID: 114633891711833786}
59155909
minDistanceToEdges: 10
59165910
--- !u!114 &114582105816722586
59175911
MonoBehaviour:
@@ -6521,6 +6515,7 @@ MonoBehaviour:
65216515
m_Script: {fileID: 11500000, guid: e63253265f9892b4f903968d5f58c0f0, type: 3}
65226516
m_Name:
65236517
m_EditorClassIdentifier:
6518+
titleLabel: {fileID: 114875424048882362}
65246519
deletedItems:
65256520
- {fileID: 1993517787700380}
65266521
- {fileID: 1662553362089260}
@@ -7331,7 +7326,7 @@ RectTransform:
73317326
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
73327327
m_AnchorMin: {x: 0, y: 1}
73337328
m_AnchorMax: {x: 1, y: 1}
7334-
m_AnchoredPosition: {x: 0, y: 0.0000076293945}
7329+
m_AnchoredPosition: {x: 0, y: -0.000015258789}
73357330
m_SizeDelta: {x: 0, y: 0}
73367331
m_Pivot: {x: 0, y: 1}
73377332
--- !u!224 &224000010499347580
@@ -7425,7 +7420,7 @@ RectTransform:
74257420
m_AnchorMin: {x: 0, y: 0}
74267421
m_AnchorMax: {x: 1, y: 1}
74277422
m_AnchoredPosition: {x: 0, y: -0.5}
7428-
m_SizeDelta: {x: -20, y: -13}
7423+
m_SizeDelta: {x: -14, y: -1}
74297424
m_Pivot: {x: 0.5, y: 0.5}
74307425
--- !u!224 &224000010798928374
74317426
RectTransform:
@@ -7560,7 +7555,7 @@ RectTransform:
75607555
m_AnchorMin: {x: 0, y: 0}
75617556
m_AnchorMax: {x: 1, y: 1}
75627557
m_AnchoredPosition: {x: 0, y: -0.5}
7563-
m_SizeDelta: {x: -20, y: -13}
7558+
m_SizeDelta: {x: -14, y: -1}
75647559
m_Pivot: {x: 0.5, y: 0.5}
75657560
--- !u!224 &224000011367034048
75667561
RectTransform:
@@ -7616,8 +7611,8 @@ RectTransform:
76167611
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
76177612
m_AnchorMin: {x: 0, y: 0}
76187613
m_AnchorMax: {x: 1, y: 1}
7619-
m_AnchoredPosition: {x: -7.5, y: -0.5}
7620-
m_SizeDelta: {x: -35, y: -13}
7614+
m_AnchoredPosition: {x: -9, y: -0.5}
7615+
m_SizeDelta: {x: -32, y: -1}
76217616
m_Pivot: {x: 0.5, y: 0.5}
76227617
--- !u!224 &224000011406587750
76237618
RectTransform:
@@ -7963,7 +7958,7 @@ RectTransform:
79637958
m_AnchorMin: {x: 0, y: 0}
79647959
m_AnchorMax: {x: 1, y: 1}
79657960
m_AnchoredPosition: {x: 0, y: -0.5}
7966-
m_SizeDelta: {x: -20, y: -13}
7961+
m_SizeDelta: {x: -14, y: -1}
79677962
m_Pivot: {x: 0.5, y: 0.5}
79687963
--- !u!224 &224000012931849942
79697964
RectTransform:
@@ -7981,7 +7976,7 @@ RectTransform:
79817976
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
79827977
m_AnchorMin: {x: 0, y: 1}
79837978
m_AnchorMax: {x: 1, y: 1}
7984-
m_AnchoredPosition: {x: 0, y: -0.000061035156}
7979+
m_AnchoredPosition: {x: 0, y: 300}
79857980
m_SizeDelta: {x: 0, y: 300}
79867981
m_Pivot: {x: 0, y: 1}
79877982
--- !u!224 &224000013035464314
@@ -8018,7 +8013,7 @@ RectTransform:
80188013
m_AnchorMin: {x: 0, y: 0}
80198014
m_AnchorMax: {x: 1, y: 1}
80208015
m_AnchoredPosition: {x: 9, y: -0.5}
8021-
m_SizeDelta: {x: -28, y: -3}
8016+
m_SizeDelta: {x: -28, y: -1}
80228017
m_Pivot: {x: 0.5, y: 0.5}
80238018
--- !u!224 &224000013343736860
80248019
RectTransform:
@@ -8036,7 +8031,7 @@ RectTransform:
80368031
m_AnchorMin: {x: 0, y: 0}
80378032
m_AnchorMax: {x: 1, y: 1}
80388033
m_AnchoredPosition: {x: 5, y: -0.5}
8039-
m_SizeDelta: {x: -30, y: -3}
8034+
m_SizeDelta: {x: -30, y: -1}
80408035
m_Pivot: {x: 0.5, y: 0.5}
80418036
--- !u!224 &224000013440901968
80428037
RectTransform:
@@ -8342,7 +8337,7 @@ RectTransform:
83428337
m_AnchorMin: {x: 0, y: 0}
83438338
m_AnchorMax: {x: 1, y: 1}
83448339
m_AnchoredPosition: {x: 0, y: -0.5}
8345-
m_SizeDelta: {x: -20, y: -13}
8340+
m_SizeDelta: {x: -14, y: -1}
83468341
m_Pivot: {x: 0.5, y: 0.5}
83478342
--- !u!224 &224009688569940338
83488343
RectTransform:
@@ -8606,8 +8601,8 @@ RectTransform:
86068601
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
86078602
m_AnchorMin: {x: 0, y: 0}
86088603
m_AnchorMax: {x: 1, y: 1}
8609-
m_AnchoredPosition: {x: 4, y: -0.5}
8610-
m_SizeDelta: {x: -12, y: -13}
8604+
m_AnchoredPosition: {x: 2.5, y: -0.5}
8605+
m_SizeDelta: {x: -9, y: -1}
86118606
m_Pivot: {x: 0.5, y: 0.5}
86128607
--- !u!224 &224366934613293246
86138608
RectTransform:
@@ -8811,7 +8806,7 @@ RectTransform:
88118806
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
88128807
m_AnchorMin: {x: 0, y: 1}
88138808
m_AnchorMax: {x: 0, y: 1}
8814-
m_AnchoredPosition: {x: 508.22507, y: -250}
8809+
m_AnchoredPosition: {x: 508.22495, y: -250}
88158810
m_SizeDelta: {x: 490.6815, y: 290.21393}
88168811
m_Pivot: {x: 0.5, y: 0.5}
88178812
--- !u!224 &224579978660468938

0 commit comments

Comments
 (0)