@@ -11,7 +11,16 @@ namespace FairyGUI
11
11
{
12
12
public interface IAsyncResource
13
13
{
14
- void LoadResource ( string assetName , string extension , PackageItemType type , Action < bool , string , object > action ) ;
14
+ /// <summary>
15
+ /// 加载资源
16
+ /// </summary>
17
+ /// <param name="assetName">资源名称</param>
18
+ /// <param name="uiPackageName">UI包名称</param>
19
+ /// <param name="extension">扩展名</param>
20
+ /// <param name="type">资源类型</param>
21
+ /// <param name="action"></param>
22
+ void LoadResource ( string assetName , string uiPackageName , string extension , PackageItemType type , Action < bool , string , object > action ) ;
23
+
15
24
void ReleaseResource ( object obj ) ;
16
25
}
17
26
@@ -372,8 +381,14 @@ public static void SetAsyncLoadResource(IAsyncResource asyncLoadResource)
372
381
public static void AddPackageAsync ( string assetPath , Action < UIPackage > callback )
373
382
{
374
383
var assetName = assetPath + "_fui.bytes" ;
384
+ var packageName = Path . GetFileNameWithoutExtension ( assetPath ) ;
385
+ if ( packageName . EndsWith ( "_fui" ) )
386
+ {
387
+ packageName = packageName . Replace ( "_fui" , string . Empty ) ;
388
+ }
389
+
375
390
var extension = Path . GetExtension ( assetName ) ;
376
- _asyncLoadResource . LoadResource ( assetName , extension , PackageItemType . Misc , ( ok , loadAssetName , asset ) =>
391
+ _asyncLoadResource . LoadResource ( assetName , packageName , extension , PackageItemType . Misc , ( ok , loadAssetName , asset ) =>
377
392
{
378
393
if ( ok )
379
394
{
@@ -750,7 +765,7 @@ void LoadResourceComplete(bool ok, string loadAssetName, object o)
750
765
foreach ( var assetName in _loadlist )
751
766
{
752
767
string extension = Path . GetExtension ( assetName . Key ) ;
753
- _asyncLoadResource . LoadResource ( assetName . Key , extension , assetName . Value , LoadResourceComplete ) ;
768
+ _asyncLoadResource . LoadResource ( assetName . Key , name , extension , assetName . Value , LoadResourceComplete ) ;
754
769
}
755
770
}
756
771
else
@@ -1595,7 +1610,7 @@ void LoadMovieClip(PackageItem item)
1595
1610
if ( spriteId != null && _sprites . TryGetValue ( spriteId , out sprite ) )
1596
1611
{
1597
1612
frame . texture = new NTexture ( ( NTexture ) GetItemAsset ( sprite . atlas ) , sprite . rect , sprite . rotated ,
1598
- new Vector2 ( item . width , item . height ) , frameRect . position ) ;
1613
+ new Vector2 ( item . width , item . height ) , frameRect . position ) ;
1599
1614
}
1600
1615
1601
1616
item . frames [ i ] = frame ;
@@ -1674,15 +1689,15 @@ void LoadFont(PackageItem item)
1674
1689
if ( mainSprite . rotated )
1675
1690
{
1676
1691
bg . uv [ 0 ] = new Vector2 ( ( float ) ( by + bgHeight + mainSprite . rect . x ) * texScaleX ,
1677
- 1 - ( float ) ( mainSprite . rect . yMax - bx ) * texScaleY ) ;
1692
+ 1 - ( float ) ( mainSprite . rect . yMax - bx ) * texScaleY ) ;
1678
1693
bg . uv [ 1 ] = new Vector2 ( bg . uv [ 0 ] . x - ( float ) bgHeight * texScaleX , bg . uv [ 0 ] . y ) ;
1679
1694
bg . uv [ 2 ] = new Vector2 ( bg . uv [ 1 ] . x , bg . uv [ 0 ] . y + ( float ) bgWidth * texScaleY ) ;
1680
1695
bg . uv [ 3 ] = new Vector2 ( bg . uv [ 0 ] . x , bg . uv [ 2 ] . y ) ;
1681
1696
}
1682
1697
else
1683
1698
{
1684
1699
bg . uv [ 0 ] = new Vector2 ( ( float ) ( bx + mainSprite . rect . x ) * texScaleX ,
1685
- 1 - ( float ) ( by + bgHeight + mainSprite . rect . y ) * texScaleY ) ;
1700
+ 1 - ( float ) ( by + bgHeight + mainSprite . rect . y ) * texScaleY ) ;
1686
1701
bg . uv [ 1 ] = new Vector2 ( bg . uv [ 0 ] . x , bg . uv [ 0 ] . y + ( float ) bgHeight * texScaleY ) ;
1687
1702
bg . uv [ 2 ] = new Vector2 ( bg . uv [ 0 ] . x + ( float ) bgWidth * texScaleX , bg . uv [ 1 ] . y ) ;
1688
1703
bg . uv [ 3 ] = new Vector2 ( bg . uv [ 2 ] . x , bg . uv [ 0 ] . y ) ;
0 commit comments