|
@@ -2,7 +2,7 @@
|
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
using YooAsset;
|
|
|
-using ET;
|
|
|
+using System.Threading.Tasks;
|
|
|
|
|
|
namespace GFGGame
|
|
|
{
|
|
@@ -24,23 +24,55 @@ namespace GFGGame
|
|
|
var handle = YooAssets.LoadAssetSync<TextAsset>($"{descFilePath}_fui.bytes");
|
|
|
TextAsset textAsset = handle.AssetObject as TextAsset;
|
|
|
CacheAssetHandle(descFilePath, handle);
|
|
|
- var uiPackage = UIPackage.AddPackage(textAsset.bytes, descFilePath, (string name, string extension, System.Type type, out DestroyMethod destroyMethod) =>
|
|
|
+ //var uiPackage = UIPackage.AddPackage(textAsset.bytes, descFilePath, (string name, string extension, System.Type type, out DestroyMethod destroyMethod) =>
|
|
|
+ //{
|
|
|
+ // string location = name + extension;
|
|
|
+ // destroyMethod = DestroyMethod.None; //注意:这里一定要设置为None
|
|
|
+ // if(!YooAssets.CheckDressUpResExist(location))
|
|
|
+ // {
|
|
|
+ // return null;
|
|
|
+ // }
|
|
|
+ // var handle = YooAssets.LoadAssetSync(location, type);
|
|
|
+ // CacheAssetHandle(descFilePath, handle);
|
|
|
+ // return handle.AssetObject;
|
|
|
+ //});
|
|
|
+
|
|
|
+ var uiPackage = UIPackage.AddPackage(textAsset.bytes, descFilePath, (string name, string extension, System.Type type, PackageItem item) =>
|
|
|
{
|
|
|
string location = name + extension;
|
|
|
- destroyMethod = DestroyMethod.None; //注意:这里一定要设置为None
|
|
|
- if(!YooAssets.CheckDressUpResExist(location))
|
|
|
+ if (!YooAssets.CheckDressUpResExist(location))
|
|
|
{
|
|
|
- return null;
|
|
|
+ return;
|
|
|
}
|
|
|
- var handle = YooAssets.LoadAssetSync(location, type);
|
|
|
+ AssetOperationHandle handle = YooAssets.LoadAssetAsync(location, type);
|
|
|
CacheAssetHandle(descFilePath, handle);
|
|
|
- return handle.AssetObject;
|
|
|
+ handle.Completed += (handle) =>
|
|
|
+ {
|
|
|
+ if (handle.AssetObject == null) return;
|
|
|
+ Texture tex = handle.AssetObject as Texture;
|
|
|
+ if (tex != null)
|
|
|
+ {
|
|
|
+ string location = name + "!a" + extension;
|
|
|
+ if (YooAssets.CheckDressUpResExist(location))
|
|
|
+ {
|
|
|
+ AssetOperationHandle handleAlpha = YooAssets.LoadAssetAsync(location, type);
|
|
|
+ CacheAssetHandle(descFilePath, handleAlpha);
|
|
|
+ handleAlpha.Completed += (handle1) =>
|
|
|
+ {
|
|
|
+ if (handle1.AssetObject == null) return;
|
|
|
+ Texture alphaTex = handle1.AssetObject as Texture;
|
|
|
+ item.owner.SetItemAsset(item, tex, alphaTex, DestroyMethod.None);//注意:这里一定要设置为None
|
|
|
+ };
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.owner.SetItemAsset(item, handle.AssetObject, null, DestroyMethod.None);//注意:这里一定要设置为None
|
|
|
+ };
|
|
|
});
|
|
|
-
|
|
|
_packages.Add(descFilePath, uiPackage);
|
|
|
}
|
|
|
|
|
|
- public static async ETTask AddPackageAsync(string descFilePath)
|
|
|
+ public static async Task AddPackageAsync(string descFilePath)
|
|
|
{
|
|
|
_assetCount.TryGetValue(descFilePath, out var count);
|
|
|
if (count > 0)
|
|
@@ -66,7 +98,7 @@ namespace GFGGame
|
|
|
{
|
|
|
if (handle.AssetObject == null) return;
|
|
|
Texture tex = handle.AssetObject as Texture;
|
|
|
- if(tex != null)
|
|
|
+ if (tex != null)
|
|
|
{
|
|
|
string location = name + "!a" + extension;
|
|
|
if (YooAssets.CheckDressUpResExist(location))
|