11using System . Collections . Generic ;
22using System . IO ;
3+ using System . Linq ;
34using System . Text ;
45using UnityEditor ;
56using UnityEngine ;
@@ -20,18 +21,18 @@ public static void Open()
2021 GetWindow < AssetQuickAccessWindow > ( ) ;
2122 }
2223
23- public static void AddItems ( IList < UObject > objects , IList < string > paths , IList < string > urls )
24+ public static void AddItems ( IList < UObject > objects , IList < string > paths , IList < ( string url , string title ) > urlInfos )
2425 {
2526 HashSet < UObject > objectHashSet = new HashSet < UObject > ( ) ;
2627 if ( objects != null )
2728 {
2829 objectHashSet = new HashSet < UObject > ( objects ) ;
2930 }
3031
31- HashSet < string > stringHashSet = null ; // For paths and urls
32+ HashSet < string > pathHashSet = null ;
3233 if ( paths != null )
3334 {
34- stringHashSet = new HashSet < string > ( ) ;
35+ pathHashSet = new HashSet < string > ( ) ;
3536 foreach ( string rawPath in paths )
3637 {
3738 string path = rawPath . Replace ( Path . DirectorySeparatorChar , Path . AltDirectorySeparatorChar ) ;
@@ -52,32 +53,31 @@ public static void AddItems(IList<UObject> objects, IList<string> paths, IList<s
5253 }
5354 else
5455 {
55- stringHashSet . Add ( rawPath ) ;
56+ pathHashSet . Add ( rawPath ) ;
5657 }
5758 }
5859 }
5960
6061 StringBuilder errorsBuilder = null ;
6162 bool added = AssetQuickAccessLocalCache . instance . AddObjects ( objectHashSet , ref errorsBuilder , false ) ;
62- if ( stringHashSet != null )
63+ if ( pathHashSet != null )
6364 {
64- added |= AssetQuickAccessLocalCache . instance . AddExternalPaths ( stringHashSet , ref errorsBuilder , false ) ;
65+ added |= AssetQuickAccessLocalCache . instance . AddExternalPaths ( pathHashSet , ref errorsBuilder , false ) ;
6566 }
6667
67- if ( urls != null )
68+ if ( urlInfos != null )
6869 {
69- stringHashSet ? . Clear ( ) ;
70- if ( stringHashSet == null )
70+ Dictionary < string , ( string url , string title ) > urlDict = new Dictionary < string , ( string url , string title ) > ( ) ;
71+ for ( int i = 0 ; i < urlInfos . Count ; i ++ )
7172 {
72- stringHashSet = new HashSet < string > ( ) ;
73- }
74-
75- for ( int i = 0 ; i < urls . Count ; i ++ )
76- {
77- stringHashSet . Add ( urls [ i ] ) ;
73+ string url = urlInfos [ i ] . url ;
74+ if ( ! urlDict . ContainsKey ( url ) )
75+ {
76+ urlDict . Add ( url , urlInfos [ i ] ) ;
77+ }
7878 }
7979
80- added |= AssetQuickAccessLocalCache . instance . AddUrls ( stringHashSet , ref errorsBuilder , false ) ;
80+ added |= AssetQuickAccessLocalCache . instance . AddUrls ( urlDict . Values , ref errorsBuilder , false ) ;
8181 }
8282
8383 if ( _instance )
@@ -274,14 +274,14 @@ private void AddUrlEditor()
274274 UrlEditWindow . Open ( center , AddUrl ) ;
275275 }
276276
277- private void AddUrl ( string url )
277+ private void AddUrl ( string url , string title )
278278 {
279279 if ( string . IsNullOrWhiteSpace ( url ) )
280280 {
281281 return ;
282282 }
283283
284- AddItems ( null , null , new string [ ] { url } ) ;
284+ AddItems ( null , null , new ( string url , string title ) [ ] { ( url , title ) } ) ;
285285 }
286286
287287 #endregion
0 commit comments