@@ -243,10 +243,11 @@ private static FileBrowser Instance
243
243
#pragma warning disable 0414
244
244
[ SerializeField ]
245
245
private QuickLink [ ] quickLinks ;
246
+ private static bool quickLinksInitialized ;
246
247
#pragma warning restore 0414
247
248
248
- private HashSet < string > excludedExtensionsSet ;
249
- private HashSet < string > addedQuickLinksSet ;
249
+ private readonly HashSet < string > excludedExtensionsSet = new HashSet < string > ( ) ;
250
+ private readonly HashSet < string > addedQuickLinksSet = new HashSet < string > ( ) ;
250
251
251
252
[ SerializeField ]
252
253
private bool generateQuickLinksForDrives = true ;
@@ -489,9 +490,6 @@ private void Awake()
489
490
490
491
filenameInputField . onValidateInput += OnValidateFilenameInput ;
491
492
492
- InitializeQuickLinks ( ) ;
493
- quickLinks = null ;
494
-
495
493
allFilesFilter = new Filter ( ALL_FILES_FILTER_TEXT ) ;
496
494
filters . Add ( allFilesFilter ) ;
497
495
@@ -573,8 +571,6 @@ private void InitializeFiletypeIcons()
573
571
574
572
private void InitializeQuickLinks ( )
575
573
{
576
- addedQuickLinksSet = new HashSet < string > ( ) ;
577
-
578
574
Vector2 anchoredPos = new Vector2 ( 0f , - quickLinksContainer . sizeDelta . y ) ;
579
575
580
576
#if ! UNITY_EDITOR && UNITY_ANDROID
@@ -584,10 +580,6 @@ private void InitializeQuickLinks()
584
580
if ( generateQuickLinksForDrives )
585
581
{
586
582
#if ! UNITY_EDITOR && UNITY_ANDROID
587
- // Fetching the list of external drives is only possible with the READ_EXTERNAL_STORAGE permission granted on Android
588
- if ( AskPermissions )
589
- RequestPermission ( ) ;
590
-
591
583
string drivesList = FileBrowserHelpers . AJC . CallStatic < string > ( "GetExternalDrives" ) ;
592
584
if ( drivesList != null && drivesList . Length > 0 )
593
585
{
@@ -652,6 +644,8 @@ private void InitializeQuickLinks()
652
644
653
645
AddQuickLink ( quickLink . icon , quickLink . name , quickLinkPath , ref anchoredPos ) ;
654
646
}
647
+
648
+ quickLinks = null ;
655
649
#endif
656
650
#if ! UNITY_EDITOR && UNITY_ANDROID
657
651
}
@@ -983,6 +977,12 @@ public void Show( string initialPath )
983
977
if ( AskPermissions )
984
978
RequestPermission ( ) ;
985
979
980
+ if ( ! quickLinksInitialized )
981
+ {
982
+ quickLinksInitialized = true ;
983
+ InitializeQuickLinks ( ) ;
984
+ }
985
+
986
986
SelectedFile = null ;
987
987
988
988
m_searchString = string . Empty ;
@@ -1283,6 +1283,17 @@ public static bool AddQuickLink( string name, string path, Sprite icon = null )
1283
1283
return false ;
1284
1284
#endif
1285
1285
1286
+ if ( ! quickLinksInitialized )
1287
+ {
1288
+ quickLinksInitialized = true ;
1289
+
1290
+ // Fetching the list of external drives is only possible with the READ_EXTERNAL_STORAGE permission granted on Android
1291
+ if ( AskPermissions )
1292
+ RequestPermission ( ) ;
1293
+
1294
+ Instance . InitializeQuickLinks ( ) ;
1295
+ }
1296
+
1286
1297
Vector2 anchoredPos = new Vector2 ( 0f , - Instance . quickLinksContainer . sizeDelta . y ) ;
1287
1298
1288
1299
if ( Instance . AddQuickLink ( icon , name , path , ref anchoredPos ) )
@@ -1296,10 +1307,7 @@ public static bool AddQuickLink( string name, string path, Sprite icon = null )
1296
1307
1297
1308
public static void SetExcludedExtensions ( params string [ ] excludedExtensions )
1298
1309
{
1299
- if ( Instance . excludedExtensionsSet == null )
1300
- Instance . excludedExtensionsSet = new HashSet < string > ( ) ;
1301
- else
1302
- Instance . excludedExtensionsSet . Clear ( ) ;
1310
+ Instance . excludedExtensionsSet . Clear ( ) ;
1303
1311
1304
1312
if ( excludedExtensions != null )
1305
1313
{
0 commit comments