Skip to content

Commit 9d7fe61

Browse files
committed
[增加]1. 增加加载资源的时候的包名返回
1 parent 53bce77 commit 9d7fe61

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

Runtime/UI/UIPackage.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ namespace FairyGUI
1111
{
1212
public interface IAsyncResource
1313
{
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+
1524
void ReleaseResource(object obj);
1625
}
1726

@@ -372,8 +381,14 @@ public static void SetAsyncLoadResource(IAsyncResource asyncLoadResource)
372381
public static void AddPackageAsync(string assetPath, Action<UIPackage> callback)
373382
{
374383
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+
375390
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) =>
377392
{
378393
if (ok)
379394
{
@@ -750,7 +765,7 @@ void LoadResourceComplete(bool ok, string loadAssetName, object o)
750765
foreach (var assetName in _loadlist)
751766
{
752767
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);
754769
}
755770
}
756771
else
@@ -1595,7 +1610,7 @@ void LoadMovieClip(PackageItem item)
15951610
if (spriteId != null && _sprites.TryGetValue(spriteId, out sprite))
15961611
{
15971612
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);
15991614
}
16001615

16011616
item.frames[i] = frame;
@@ -1674,15 +1689,15 @@ void LoadFont(PackageItem item)
16741689
if (mainSprite.rotated)
16751690
{
16761691
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);
16781693
bg.uv[1] = new Vector2(bg.uv[0].x - (float)bgHeight * texScaleX, bg.uv[0].y);
16791694
bg.uv[2] = new Vector2(bg.uv[1].x, bg.uv[0].y + (float)bgWidth * texScaleY);
16801695
bg.uv[3] = new Vector2(bg.uv[0].x, bg.uv[2].y);
16811696
}
16821697
else
16831698
{
16841699
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);
16861701
bg.uv[1] = new Vector2(bg.uv[0].x, bg.uv[0].y + (float)bgHeight * texScaleY);
16871702
bg.uv[2] = new Vector2(bg.uv[0].x + (float)bgWidth * texScaleX, bg.uv[1].y);
16881703
bg.uv[3] = new Vector2(bg.uv[2].x, bg.uv[0].y);

0 commit comments

Comments
 (0)