Skip to content

Commit ace9a49

Browse files
committed
Added FileBrowser.CanDeleteFiles and CanRenameFiles properties to disable deleting/renaming files via file browser UI
1 parent 1750c04 commit ace9a49

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

Plugins/SimpleFileBrowser/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Simple File Browser (v1.7.0) =
1+
= Simple File Browser (v1.7.1) =
22

33
Documentation: https://github.com/yasirkula/UnitySimpleFileBrowser
44
FAQ: https://github.com/yasirkula/UnitySimpleFileBrowser#faq

Plugins/SimpleFileBrowser/Resources/SimpleFileBrowserCanvas.prefab

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,7 +2732,7 @@ RectTransform:
27322732
m_GameObject: {fileID: 1000011817404238}
27332733
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
27342734
m_LocalPosition: {x: 0, y: 0, z: 0}
2735-
m_LocalScale: {x: 1.4691666, y: 1.4691666, z: 1.4691666}
2735+
m_LocalScale: {x: 0, y: 0, z: 0}
27362736
m_ConstrainProportionsScale: 0
27372737
m_Children:
27382738
- {fileID: 224000012589068232}
@@ -2747,7 +2747,7 @@ RectTransform:
27472747
m_AnchorMax: {x: 0, y: 0}
27482748
m_AnchoredPosition: {x: 0, y: 0}
27492749
m_SizeDelta: {x: 0, y: 0}
2750-
m_Pivot: {x: 0.5, y: 0.5}
2750+
m_Pivot: {x: 0, y: 0}
27512751
--- !u!223 &223000012645506472
27522752
Canvas:
27532753
m_ObjectHideFlags: 0
@@ -2840,8 +2840,6 @@ MonoBehaviour:
28402840
name: Desktop
28412841
icon: {fileID: 0}
28422842
generateQuickLinksForDrives: 1
2843-
contextMenuShowDeleteButton: 1
2844-
contextMenuShowRenameButton: 1
28452843
showResizeCursor: 1
28462844
window: {fileID: 114000011184475620}
28472845
windowResponsiveRows:

Plugins/SimpleFileBrowser/Scripts/FileBrowser.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ public static bool CheckWriteAccessToDestinationDirectory
222222
set { m_checkWriteAccessToDestinationDirectory = value; }
223223
}
224224

225+
public static bool CanDeleteFiles = true;
226+
public static bool CanRenameFiles = true;
227+
225228
#if UNITY_EDITOR || ( !UNITY_ANDROID && !UNITY_IOS && !UNITY_WSA && !UNITY_WSA_10_0 )
226229
private static float m_drivesRefreshInterval = 5f;
227230
#else
@@ -379,12 +382,6 @@ public static FileBrowser Instance
379382
[SerializeField]
380383
private bool generateQuickLinksForDrives = true;
381384

382-
[SerializeField]
383-
private bool contextMenuShowDeleteButton = true;
384-
385-
[SerializeField]
386-
private bool contextMenuShowRenameButton = true;
387-
388385
[SerializeField]
389386
private bool showResizeCursor = true;
390387

@@ -1363,8 +1360,8 @@ private void ShowContextMenuAt( Vector2 position, bool isMoreOptionsMenu )
13631360

13641361
bool selectAllButtonVisible = isMoreOptionsMenu && m_allowMultiSelection && validFileEntries.Count > 0;
13651362
bool deselectAllButtonVisible = isMoreOptionsMenu && selectedFileEntries.Count > 1;
1366-
bool deleteButtonVisible = contextMenuShowDeleteButton && selectedFileEntries.Count > 0;
1367-
bool renameButtonVisible = contextMenuShowRenameButton && selectedFileEntries.Count == 1;
1363+
bool deleteButtonVisible = CanDeleteFiles && selectedFileEntries.Count > 0;
1364+
bool renameButtonVisible = CanRenameFiles && selectedFileEntries.Count == 1;
13681365

13691366
if( selectAllButtonVisible && m_pickerMode == PickMode.Files )
13701367
{
@@ -2259,7 +2256,7 @@ private IEnumerator CreateNewFolderCoroutine()
22592256
// Prompts user to rename the selected file/folder
22602257
public void RenameSelectedFile()
22612258
{
2262-
if( selectedFileEntries.Count != 1 )
2259+
if( !CanRenameFiles || selectedFileEntries.Count != 1 )
22632260
return;
22642261

22652262
MultiSelectionToggleSelectionMode = false;
@@ -2320,7 +2317,7 @@ public void RenameSelectedFile()
23202317
// Prompts user to delete the selected files & folders
23212318
public void DeleteSelectedFiles()
23222319
{
2323-
if( selectedFileEntries.Count == 0 )
2320+
if( !CanDeleteFiles || selectedFileEntries.Count == 0 )
23242321
return;
23252322

23262323
selectedFileEntries.Sort();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.yasirkula.simplefilebrowser",
33
"displayName": "Simple File Browser",
4-
"version": "1.7.0",
4+
"version": "1.7.1",
55
"documentationUrl": "https://github.com/yasirkula/UnitySimpleFileBrowser",
66
"changelogUrl": "https://github.com/yasirkula/UnitySimpleFileBrowser/releases",
77
"licensesUrl": "https://github.com/yasirkula/UnitySimpleFileBrowser/blob/master/LICENSE.txt",

0 commit comments

Comments
 (0)