Skip to content

Commit

Permalink
AllFilesFilterText, FoldersFilterText and PickFolderQuickLinkText can…
Browse files Browse the repository at this point in the history
… now be changed after the file browser is initialized, as well
  • Loading branch information
yasirkula committed Dec 2, 2020
1 parent 6980dfd commit 1b007a2
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 22 deletions.
20 changes: 20 additions & 0 deletions Plugins/SimpleFileBrowser/Editor/FBPostProcessBuild.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.IO;
using UnityEditor;
using UnityEngine;

namespace SimpleFileBrowser
{
public class FBPostProcessBuild
{
[InitializeOnLoadMethod]
public static void ValidatePlugin()
{
string jarPath = "Assets/Plugins/SimpleFileBrowser/Android/SimpleFileBrowser.jar";
if( File.Exists( jarPath ) )
{
Debug.Log( "Deleting obsolete " + jarPath );
AssetDatabase.DeleteAsset( jarPath );
}
}
}
}
17 changes: 0 additions & 17 deletions Plugins/SimpleFileBrowser/Editor/SFBPostProcessBuild.cs

This file was deleted.

75 changes: 71 additions & 4 deletions Plugins/SimpleFileBrowser/Scripts/FileBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ public override string ToString()
#endregion

#region Static Variables
public static string AllFilesFilterText = "All Files (.*)";
public static string FoldersFilterText = "Folders";
public static string PickFolderQuickLinkText = "Pick Folder";

public static bool IsOpen { get; private set; }

public static bool Success { get; private set; }
Expand All @@ -128,6 +124,77 @@ public static bool SingleClickMode
set { m_singleClickMode = value; }
}

private static string m_allFilesFilterText = "All Files (.*)";
public static string AllFilesFilterText
{
get { return m_allFilesFilterText; }
set
{
if( m_allFilesFilterText != value )
{
string oldValue = m_allFilesFilterText;
m_allFilesFilterText = value;

if( m_instance )
{
Filter oldAllFilesFilter = m_instance.allFilesFilter;
m_instance.allFilesFilter = new Filter( value );

if( m_instance.filters.Count > 0 && m_instance.filters[0] == oldAllFilesFilter )
m_instance.filters[0] = m_instance.allFilesFilter;

if( m_instance.filtersDropdown.options[0].text == oldValue )
m_instance.filtersDropdown.options[0].text = value;
}
}
}
}


private static string m_foldersFilterText = "Folders";
public static string FoldersFilterText
{
get { return m_foldersFilterText; }
set
{
if( m_foldersFilterText != value )
{
string oldValue = m_foldersFilterText;
m_foldersFilterText = value;

if( m_instance && m_instance.filtersDropdown.options[0].text == oldValue )
m_instance.filtersDropdown.options[0].text = value;
}
}
}


private static string m_pickFolderQuickLinkText = "Pick Folder";
public static string PickFolderQuickLinkText
{
get { return m_pickFolderQuickLinkText; }
set
{
if( m_pickFolderQuickLinkText != value )
{
m_pickFolderQuickLinkText = value;

if( m_instance && m_instance.addedQuickLinksSet.Contains( SAF_PICK_FOLDER_QUICK_LINK_PATH ) )
{
for( int i = 0; i < m_instance.quickLinksContainer.childCount; i++ )
{
FileBrowserQuickLink quickLink = m_instance.quickLinksContainer.GetChild( i ).GetComponent<FileBrowserQuickLink>();
if( quickLink && quickLink.TargetPath == SAF_PICK_FOLDER_QUICK_LINK_PATH )
{
quickLink.SetQuickLink( m_instance.driveIcon, value, SAF_PICK_FOLDER_QUICK_LINK_PATH );
break;
}
}
}
}
}
}

private static FileBrowser m_instance = null;
private static FileBrowser Instance
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.yasirkula.simplefilebrowser",
"displayName": "Simple File Browser",
"version": "1.3.9",
"version": "1.4.0",
"description": "This plugin helps you show save/load dialogs during gameplay with its uGUI based file browser."
}

0 comments on commit 1b007a2

Please sign in to comment.