@@ -113,7 +113,7 @@ public static bool CanAddPathToBundle(string path, string bundleName)
113113 return false ;
114114 }
115115
116- string guid = AssetDatabase . AssetPathToGUID ( path ) ;
116+ string guid = GetPathGUID ( path ) ;
117117 if ( m_guidToBundle . ContainsKey ( guid ) )
118118 {
119119 return false ;
@@ -134,7 +134,7 @@ public static bool AddPathToBundle(string path, string bundleName, int size)
134134 }
135135
136136 BundleData bundle = m_dataDict [ bundleName ] ;
137- string guid = AssetDatabase . AssetPathToGUID ( path ) ;
137+ string guid = GetPathGUID ( path ) ;
138138
139139 bundle . includs . Add ( path ) ;
140140 m_guidToBundle . Add ( guid , bundleName ) ;
@@ -149,7 +149,7 @@ public static void RemovePathFromBundle(string path, string bundleName)
149149 {
150150 return ;
151151 }
152- string guid = AssetDatabase . AssetPathToGUID ( path ) ;
152+ string guid = GetPathGUID ( path ) ;
153153
154154 if ( m_guidToBundle . ContainsKey ( guid ) )
155155 {
@@ -158,7 +158,7 @@ public static void RemovePathFromBundle(string path, string bundleName)
158158
159159 for ( int i = 0 ; i < bundle . includs . Count ; ++ i )
160160 {
161- string nGuid = AssetDatabase . AssetPathToGUID ( bundle . includs [ i ] ) ;
161+ string nGuid = GetPathGUID ( bundle . includs [ i ] ) ;
162162 if ( nGuid == guid )
163163 {
164164 bundle . includs . RemoveAt ( i ) ;
@@ -185,7 +185,7 @@ public static bool RemoveBundle(string bundleName)
185185
186186 for ( int i = 0 ; i < bundle . includs . Count ; ++ i )
187187 {
188- string nGuid = AssetDatabase . AssetPathToGUID ( bundle . includs [ i ] ) ;
188+ string nGuid = GetPathGUID ( bundle . includs [ i ] ) ;
189189 m_guidToBundle . Remove ( nGuid ) ;
190190 }
191191
@@ -235,17 +235,25 @@ public static string GenBundleNameByType(BundleType type)
235235 }
236236 public static string GetPathBundleName ( string assetPath )
237237 {
238- string guid = AssetDatabase . AssetPathToGUID ( assetPath ) ;
238+ string guid = GetPathGUID ( assetPath ) ;
239239 string ret = string . Empty ;
240240 if ( m_guidToBundle . TryGetValue ( guid , out ret ) )
241241 {
242242 return ret ;
243243 }
244244 return string . Empty ;
245245 }
246+ public static string GetPathGUID ( string path )
247+ {
248+ if ( path . StartsWith ( "Assets/" , System . StringComparison . OrdinalIgnoreCase ) )
249+ {
250+ return AssetDatabase . AssetPathToGUID ( path ) ;
251+ }
252+ return path ;
253+ }
246254 public static bool CheckPathInBundle ( string path )
247255 {
248- string guid = AssetDatabase . AssetPathToGUID ( path ) ;
256+ string guid = GetPathGUID ( path ) ;
249257 return m_guidToBundle . ContainsKey ( guid ) ;
250258 }
251259 public static bool IsBundleFull ( BundleData bundle , int maxCount , int memSize )
@@ -309,7 +317,7 @@ public static void Init()
309317
310318 for ( int i = 0 ; i < bundleData . includs . Count ; ++ i )
311319 {
312- string guid = AssetDatabase . AssetPathToGUID ( bundleData . includs [ i ] ) ;
320+ string guid = GetPathGUID ( bundleData . includs [ i ] ) ;
313321 if ( ! m_guidToBundle . ContainsKey ( guid ) )
314322 {
315323 m_guidToBundle . Add ( guid , bundleData . name ) ;
0 commit comments