Skip to content

Commit

Permalink
Quick links fixes for Mac OS
Browse files Browse the repository at this point in the history
  • Loading branch information
yasirkula committed Sep 4, 2020
1 parent 8f8b4b9 commit 526c119
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Plugins/SimpleFileBrowser/Scripts/FileBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,27 @@ private void InitializeQuickLinks()
string[] drives = Directory.GetLogicalDrives();

for( int i = 0; i < drives.Length; i++ )
{
if( string.IsNullOrEmpty( drives[i] ) )
continue;

#if UNITY_STANDALONE_OSX
// There are a number of useless drives listed on Mac OS, filter them
if( drives[i] == "/" )
AddQuickLink( driveIcon, "Root", drives[i], ref anchoredPos );
else if( drives[i].StartsWith( "/Volumes/" ) && drives[i] != "/Volumes/Recovery" )
AddQuickLink( driveIcon, drives[i].Substring( drives[i].LastIndexOf( '/' ) + 1 ), drives[i], ref anchoredPos );
#else
AddQuickLink( driveIcon, drives[i], drives[i], ref anchoredPos );
#endif
}

#if UNITY_STANDALONE_OSX
// Add a quick link for user directory on Mac OS
string userDirectory = Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments );
if( !string.IsNullOrEmpty( userDirectory ) )
AddQuickLink( driveIcon, userDirectory.Substring( userDirectory.LastIndexOf( '/' ) + 1 ), userDirectory, ref anchoredPos );
#endif
#endif
}

Expand All @@ -668,6 +688,11 @@ private void InitializeQuickLinks()
{
QuickLink quickLink = quickLinks[i];
string quickLinkPath = Environment.GetFolderPath( quickLink.target );
#if UNITY_STANDALONE_OSX
// Documents folder must be appended manually on Mac OS
if( quickLink.target == Environment.SpecialFolder.MyDocuments && !string.IsNullOrEmpty( quickLinkPath ) )
quickLinkPath = Path.Combine( quickLinkPath, "Documents" );
#endif

AddQuickLink( quickLink.icon, quickLink.name, quickLinkPath, ref anchoredPos );
}
Expand Down
1 change: 1 addition & 0 deletions Plugins/SimpleFileBrowser/Scripts/FileBrowserItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public RectTransform TransformComponent
public void SetFileBrowser( FileBrowser fileBrowser )
{
this.fileBrowser = fileBrowser;
background.color = fileBrowser.normalFileColor;
}

public void SetFile( Sprite icon, string name, bool isDirectory )
Expand Down

0 comments on commit 526c119

Please sign in to comment.