Optimized asset system and patch system framework

优化了资源定位不正确导致的错误报告方式。
YooAssets.ProcessOperation()重命名为YooAssets.StartOperation()
YooAssets.GetBundleInfo()已经移除方法。
YooAssets.IsNeedDownloadFromRemote()新增加方法。
This commit is contained in:
hevinci
2022-05-11 16:48:17 +08:00
parent 67eeae31c7
commit 4cad587609
34 changed files with 726 additions and 573 deletions
@@ -39,31 +39,33 @@ namespace YooAsset
if (_steps == ESteps.None)
{
if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.None)
if(MainBundleInfo.IsInvalid)
{
_steps = ESteps.Done;
Status = EStatus.Failed;
LastError = $"Invalid load mode : {BundleFileInfo.BundleName}";
LastError = $"The bundle info is invalid : {MainBundleInfo.BundleName}";
YooLogger.Error(LastError);
return;
}
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
{
_steps = ESteps.Download;
_fileLoadPath = BundleFileInfo.GetCacheLoadPath();
_fileLoadPath = MainBundleInfo.GetCacheLoadPath();
}
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
{
_steps = ESteps.LoadFile;
_fileLoadPath = BundleFileInfo.GetStreamingLoadPath();
_fileLoadPath = MainBundleInfo.GetStreamingLoadPath();
}
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
{
_steps = ESteps.LoadFile;
_fileLoadPath = BundleFileInfo.GetCacheLoadPath();
_fileLoadPath = MainBundleInfo.GetCacheLoadPath();
}
else
{
throw new System.NotImplementedException(BundleFileInfo.LoadMode.ToString());
throw new System.NotImplementedException(MainBundleInfo.LoadMode.ToString());
}
}
@@ -71,7 +73,7 @@ namespace YooAsset
if (_steps == ESteps.Download)
{
int failedTryAgain = int.MaxValue;
_downloader = DownloadSystem.BeginDownload(BundleFileInfo, failedTryAgain);
_downloader = DownloadSystem.BeginDownload(MainBundleInfo, failedTryAgain);
_steps = ESteps.CheckDownload;
}
@@ -109,12 +111,12 @@ namespace YooAsset
#endif
// Load assetBundle file
if (BundleFileInfo.IsEncrypted)
if (MainBundleInfo.IsEncrypted)
{
if (AssetSystem.DecryptionServices == null)
throw new Exception($"{nameof(AssetBundleFileLoader)} need {nameof(IDecryptionServices)} : {BundleFileInfo.BundleName}");
throw new Exception($"{nameof(AssetBundleFileLoader)} need {nameof(IDecryptionServices)} : {MainBundleInfo.BundleName}");
ulong offset = AssetSystem.DecryptionServices.GetFileOffset(BundleFileInfo);
ulong offset = AssetSystem.DecryptionServices.GetFileOffset();
if (_isWaitForAsyncComplete)
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath, 0, offset);
else
@@ -154,7 +156,7 @@ namespace YooAsset
{
_steps = ESteps.Done;
Status = EStatus.Failed;
LastError = $"Failed to load assetBundle : {BundleFileInfo.BundleName}";
LastError = $"Failed to load assetBundle : {MainBundleInfo.BundleName}";
YooLogger.Error(LastError);
}
else
@@ -183,7 +185,7 @@ namespace YooAsset
if (_isShowWaitForAsyncError == false)
{
_isShowWaitForAsyncError = true;
YooLogger.Error($"WaitForAsyncComplete failed ! BundleName : {BundleFileInfo.BundleName} States : {Status}");
YooLogger.Error($"WaitForAsyncComplete failed ! BundleName : {MainBundleInfo.BundleName} States : {Status}");
}
break;
}
@@ -17,7 +17,7 @@ namespace YooAsset
/// <summary>
/// 资源包文件信息
/// </summary>
public BundleInfo BundleFileInfo { private set; get; }
public BundleInfo MainBundleInfo { private set; get; }
/// <summary>
/// 引用计数
@@ -45,7 +45,7 @@ namespace YooAsset
public AssetBundleLoaderBase(BundleInfo bundleInfo)
{
BundleFileInfo = bundleInfo;
MainBundleInfo = bundleInfo;
RefCount = 0;
Status = EStatus.None;
}
@@ -91,9 +91,9 @@ namespace YooAsset
if (forceDestroy == false)
{
if (RefCount > 0)
throw new Exception($"Bundle file loader ref is not zero : {BundleFileInfo.BundleName}");
throw new Exception($"Bundle file loader ref is not zero : {MainBundleInfo.BundleName}");
if (IsDone() == false)
throw new Exception($"Bundle file loader is not done : {BundleFileInfo.BundleName}");
throw new Exception($"Bundle file loader is not done : {MainBundleInfo.BundleName}");
}
if (CacheBundle != null)
@@ -37,28 +37,30 @@ namespace YooAsset
if (_steps == ESteps.None)
{
if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.None)
if (MainBundleInfo.IsInvalid)
{
_steps = ESteps.Done;
Status = EStatus.Failed;
LastError = $"Invalid load mode : {BundleFileInfo.BundleName}";
LastError = $"The bundle info is invalid : {MainBundleInfo.BundleName}";
YooLogger.Error(LastError);
return;
}
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
{
_steps = ESteps.LoadFile;
_webURL = BundleFileInfo.GetStreamingLoadPath();
_webURL = MainBundleInfo.GetStreamingLoadPath();
}
else
{
throw new System.NotImplementedException(BundleFileInfo.LoadMode.ToString());
throw new System.NotImplementedException(MainBundleInfo.LoadMode.ToString());
}
}
// 1. 从服务器或缓存中获取AssetBundle文件
if (_steps == ESteps.LoadFile)
{
string hash = StringUtility.RemoveExtension(BundleFileInfo.Hash);
string hash = StringUtility.RemoveExtension(MainBundleInfo.Hash);
_webRequest = UnityWebRequestAssetBundle.GetAssetBundle(_webURL, Hash128.Parse(hash));
_webRequest.SendWebRequest();
_steps = ESteps.CheckFile;
@@ -87,7 +89,7 @@ namespace YooAsset
{
_steps = ESteps.Done;
Status = EStatus.Failed;
LastError = $"AssetBundle file is invalid : {BundleFileInfo.BundleName}";
LastError = $"AssetBundle file is invalid : {MainBundleInfo.BundleName}";
YooLogger.Error(LastError);
}
else
@@ -12,9 +12,9 @@ namespace YooAsset
private readonly List<AssetBundleLoaderBase> _dependBundles;
public DependAssetBundleGroup(string assetPath)
public DependAssetBundleGroup(List<AssetBundleLoaderBase> dpendBundles)
{
_dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetPath);
_dependBundles = dpendBundles;
}
/// <summary>
@@ -102,7 +102,7 @@ namespace YooAsset
foreach (var loader in _dependBundles)
{
var bundleInfo = new DebugBundleInfo();
bundleInfo.BundleName = loader.BundleFileInfo.BundleName;
bundleInfo.BundleName = loader.MainBundleInfo.BundleName;
bundleInfo.RefCount = loader.RefCount;
bundleInfo.Status = loader.Status;
output.Add(bundleInfo);