Optimized asset system and patch system framework
优化了资源定位不正确导致的错误报告方式。 YooAssets.ProcessOperation()重命名为YooAssets.StartOperation() YooAssets.GetBundleInfo()已经移除方法。 YooAssets.IsNeedDownloadFromRemote()新增加方法。
This commit is contained in:
@@ -1,8 +1,35 @@
|
||||
|
||||
using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class AssetInfo
|
||||
{
|
||||
private readonly PatchAsset _patchAsset;
|
||||
private string _providerGUID;
|
||||
|
||||
/// <summary>
|
||||
/// 资源提供者唯一标识符
|
||||
/// </summary>
|
||||
internal string ProviderGUID
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_providerGUID) == false)
|
||||
return _providerGUID;
|
||||
|
||||
if (AssetType == null)
|
||||
_providerGUID = $"{AssetPath}[null]";
|
||||
else
|
||||
_providerGUID = $"{AssetPath}[{AssetType.Name}]";
|
||||
return _providerGUID;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象名称
|
||||
/// </summary>
|
||||
public string AssetName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
@@ -13,15 +40,55 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public System.Type AssetType { private set; get; }
|
||||
|
||||
public AssetInfo(string assetPath, System.Type assetType)
|
||||
/// <summary>
|
||||
/// 身份是否无效
|
||||
/// </summary>
|
||||
public bool IsInvalid
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
AssetType = assetType;
|
||||
get
|
||||
{
|
||||
return _patchAsset == null;
|
||||
}
|
||||
}
|
||||
public AssetInfo(string assetPath)
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// </summary>
|
||||
public string Error { private set; get; }
|
||||
|
||||
|
||||
private AssetInfo()
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
}
|
||||
internal AssetInfo(PatchAsset patchAsset, System.Type assetType)
|
||||
{
|
||||
if (patchAsset == null)
|
||||
throw new System.Exception("Should never get here !");
|
||||
|
||||
_patchAsset = patchAsset;
|
||||
AssetType = assetType;
|
||||
AssetPath = patchAsset.AssetPath;
|
||||
AssetName = Path.GetFileName(patchAsset.AssetPath);
|
||||
Error = string.Empty;
|
||||
}
|
||||
internal AssetInfo(PatchAsset patchAsset)
|
||||
{
|
||||
if (patchAsset == null)
|
||||
throw new System.Exception("Should never get here !");
|
||||
|
||||
_patchAsset = patchAsset;
|
||||
AssetType = null;
|
||||
AssetPath = patchAsset.AssetPath;
|
||||
AssetName = Path.GetFileName(patchAsset.AssetPath);
|
||||
Error = string.Empty;
|
||||
}
|
||||
internal AssetInfo(string error)
|
||||
{
|
||||
_patchAsset = null;
|
||||
AssetType = null;
|
||||
AssetPath = string.Empty;
|
||||
AssetName = string.Empty;
|
||||
Error = error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class BundleInfo
|
||||
internal class BundleInfo
|
||||
{
|
||||
internal enum ELoadMode
|
||||
public enum ELoadMode
|
||||
{
|
||||
None,
|
||||
LoadFromStreaming,
|
||||
@@ -13,7 +13,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
private readonly PatchBundle _patchBundle;
|
||||
internal readonly ELoadMode LoadMode;
|
||||
public readonly ELoadMode LoadMode;
|
||||
|
||||
private string _streamingPath;
|
||||
private string _cachePath;
|
||||
@@ -26,17 +26,17 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 远端下载地址
|
||||
/// </summary>
|
||||
internal string RemoteMainURL { private set; get; }
|
||||
public string RemoteMainURL { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 远端下载备用地址
|
||||
/// </summary>
|
||||
internal string RemoteFallbackURL { private set; get; }
|
||||
public string RemoteFallbackURL { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器资源路径
|
||||
/// </summary>
|
||||
internal string EditorAssetPath { private set; get; }
|
||||
public string EditorAssetPath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
@@ -108,11 +108,27 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 身份是否无效
|
||||
/// </summary>
|
||||
public bool IsInvalid
|
||||
{
|
||||
get
|
||||
{
|
||||
return _patchBundle == null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// </summary>
|
||||
public string Error { private set; get; }
|
||||
|
||||
|
||||
private BundleInfo()
|
||||
{
|
||||
}
|
||||
internal BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string mainURL, string fallbackURL)
|
||||
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string mainURL, string fallbackURL)
|
||||
{
|
||||
_patchBundle = patchBundle;
|
||||
LoadMode = loadMode;
|
||||
@@ -120,8 +136,9 @@ namespace YooAsset
|
||||
RemoteMainURL = mainURL;
|
||||
RemoteFallbackURL = fallbackURL;
|
||||
EditorAssetPath = string.Empty;
|
||||
Error = string.Empty;
|
||||
}
|
||||
internal BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string editorAssetPath)
|
||||
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string editorAssetPath)
|
||||
{
|
||||
_patchBundle = patchBundle;
|
||||
LoadMode = loadMode;
|
||||
@@ -129,8 +146,9 @@ namespace YooAsset
|
||||
RemoteMainURL = string.Empty;
|
||||
RemoteFallbackURL = string.Empty;
|
||||
EditorAssetPath = editorAssetPath;
|
||||
Error = string.Empty;
|
||||
}
|
||||
internal BundleInfo(PatchBundle patchBundle, ELoadMode loadMode)
|
||||
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode)
|
||||
{
|
||||
_patchBundle = patchBundle;
|
||||
LoadMode = loadMode;
|
||||
@@ -138,37 +156,23 @@ namespace YooAsset
|
||||
RemoteMainURL = string.Empty;
|
||||
RemoteFallbackURL = string.Empty;
|
||||
EditorAssetPath = string.Empty;
|
||||
Error = string.Empty;
|
||||
}
|
||||
internal BundleInfo(string bundleName)
|
||||
public BundleInfo(string error)
|
||||
{
|
||||
_patchBundle = null;
|
||||
LoadMode = ELoadMode.None;
|
||||
BundleName = bundleName;
|
||||
BundleName = string.Empty;
|
||||
RemoteMainURL = string.Empty;
|
||||
RemoteFallbackURL = string.Empty;
|
||||
EditorAssetPath = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源包是否有效
|
||||
/// </summary>
|
||||
public bool IsValid()
|
||||
{
|
||||
return _patchBundle != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源包文件是否在云端
|
||||
/// </summary>
|
||||
public bool InCloud()
|
||||
{
|
||||
return LoadMode == ELoadMode.LoadFromRemote;
|
||||
Error = error;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取流文件夹的加载路径
|
||||
/// </summary>
|
||||
internal string GetStreamingLoadPath()
|
||||
public string GetStreamingLoadPath()
|
||||
{
|
||||
if (_patchBundle == null)
|
||||
return string.Empty;
|
||||
@@ -181,7 +185,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 获取缓存文件夹的加载路径
|
||||
/// </summary>
|
||||
internal string GetCacheLoadPath()
|
||||
public string GetCacheLoadPath()
|
||||
{
|
||||
if (_patchBundle == null)
|
||||
return string.Empty;
|
||||
@@ -191,7 +195,6 @@ namespace YooAsset
|
||||
return _cachePath;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否为JAR包内文件
|
||||
/// </summary>
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
OperationSystem.ProcessOperaiton(this);
|
||||
OperationSystem.StartOperaiton(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,90 +61,6 @@ namespace YooAsset
|
||||
private bool _locationToLower = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置资源标签列表
|
||||
/// </summary>
|
||||
public string[] GetBuildinTags()
|
||||
{
|
||||
return StringUtility.StringToStringList(BuildinTags, ';').ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源依赖列表
|
||||
/// </summary>
|
||||
public string[] GetAllDependencies(string assetPath)
|
||||
{
|
||||
if (Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
||||
{
|
||||
List<string> result = new List<string>(patchAsset.DependIDs.Length);
|
||||
foreach (var dependID in patchAsset.DependIDs)
|
||||
{
|
||||
if (dependID >= 0 && dependID < BundleList.Count)
|
||||
{
|
||||
var dependPatchBundle = BundleList[dependID];
|
||||
result.Add(dependPatchBundle.BundleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid bundle id : {dependID} Asset path : {assetPath}");
|
||||
}
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Not found asset path in patch manifest : {assetPath}");
|
||||
return new string[] { };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包名称
|
||||
/// </summary>
|
||||
public string GetBundleName(string assetPath)
|
||||
{
|
||||
if (Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
||||
{
|
||||
int bundleID = patchAsset.BundleID;
|
||||
if (bundleID >= 0 && bundleID < BundleList.Count)
|
||||
{
|
||||
var patchBundle = BundleList[bundleID];
|
||||
return patchBundle.BundleName;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid bundle id : {bundleID} Asset path : {assetPath}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Not found asset path in patch manifest : {assetPath}");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试获取资源包的主资源路径
|
||||
/// </summary>
|
||||
public string TryGetBundleMainAssetPath(string bundleName)
|
||||
{
|
||||
foreach (var patchAsset in AssetList)
|
||||
{
|
||||
int bundleID = patchAsset.BundleID;
|
||||
if (bundleID >= 0 && bundleID < BundleList.Count)
|
||||
{
|
||||
var patchBundle = BundleList[bundleID];
|
||||
if (patchBundle.BundleName == bundleName)
|
||||
return patchAsset.AssetPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid bundle id : {bundleID} Asset path : {patchAsset.AssetPath}");
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源路径映射
|
||||
/// </summary>
|
||||
@@ -201,6 +117,12 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public string MappingToAssetPath(string location)
|
||||
{
|
||||
if(string.IsNullOrEmpty(location))
|
||||
{
|
||||
YooLogger.Error("Failed to mapping location to asset path, The location is null or empty.");
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (_locationToLower)
|
||||
location = location.ToLower();
|
||||
|
||||
@@ -210,11 +132,65 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Error($"Failed to mapping location to asset path : {location}");
|
||||
YooLogger.Warning($"Failed to mapping location to asset path : {location}");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包名称
|
||||
/// 注意:传入的资源路径一定合法有效!
|
||||
/// </summary>
|
||||
public string GetBundleName(string assetPath)
|
||||
{
|
||||
if (Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
||||
{
|
||||
int bundleID = patchAsset.BundleID;
|
||||
if (bundleID >= 0 && bundleID < BundleList.Count)
|
||||
{
|
||||
var patchBundle = BundleList[bundleID];
|
||||
return patchBundle.BundleName;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid bundle id : {bundleID} Asset path : {assetPath}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Should never get here !");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源依赖列表
|
||||
/// 注意:传入的资源路径一定合法有效!
|
||||
/// </summary>
|
||||
public string[] GetAllDependencies(string assetPath)
|
||||
{
|
||||
if (Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
||||
{
|
||||
List<string> result = new List<string>(patchAsset.DependIDs.Length);
|
||||
foreach (var dependID in patchAsset.DependIDs)
|
||||
{
|
||||
if (dependID >= 0 && dependID < BundleList.Count)
|
||||
{
|
||||
var dependPatchBundle = BundleList[dependID];
|
||||
result.Add(dependPatchBundle.BundleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid bundle id : {dependID} Asset path : {assetPath}");
|
||||
}
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Should never get here !");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 序列化
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace YooAsset
|
||||
{
|
||||
_locationToLower = locationToLower;
|
||||
var operation = new EditorSimulateModeInitializationOperation(this, simulatePatchManifestPath);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
OperationSystem.StartOperaiton(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -38,44 +38,41 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
#region IBundleServices接口
|
||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
return new BundleInfo(string.Empty);
|
||||
if(assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
string bundleName = _simulatePatchManifest.GetBundleName(assetInfo.AssetPath);
|
||||
if (_simulatePatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||
{
|
||||
string mainAssetPath = _simulatePatchManifest.TryGetBundleMainAssetPath(bundleName);
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, mainAssetPath);
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath);
|
||||
return bundleInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
||||
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||
return bundleInfo;
|
||||
throw new Exception("Should never get here !");
|
||||
}
|
||||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string bundleName)
|
||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
return PatchHelper.GetAssetsInfoByBundleName(_simulatePatchManifest, bundleName);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||
{
|
||||
return PatchHelper.GetAssetsInfoByTags(_simulatePatchManifest, tags);
|
||||
}
|
||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||
{
|
||||
if (_simulatePatchManifest.Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
||||
return patchAsset;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return _simulatePatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetBundleName(string assetPath)
|
||||
{
|
||||
return _simulatePatchManifest.GetBundleName(assetPath);
|
||||
}
|
||||
string[] IBundleServices.GetAllDependencies(string assetPath)
|
||||
{
|
||||
return _simulatePatchManifest.GetAllDependencies(assetPath);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace YooAsset
|
||||
_fallbackHostServer = fallbackHostServer;
|
||||
|
||||
var operation = new HostPlayModeInitializationOperation(this);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
OperationSystem.StartOperaiton(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace YooAsset
|
||||
public UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout)
|
||||
{
|
||||
var operation = new HostPlayModeUpdateStaticVersionOperation(this, timeout);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
OperationSystem.StartOperaiton(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace YooAsset
|
||||
public UpdateManifestOperation UpdatePatchManifestAsync(int resourceVersion, int timeout)
|
||||
{
|
||||
var operation = new HostPlayModeUpdateManifestOperation(this, resourceVersion, timeout);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
OperationSystem.StartOperaiton(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace YooAsset
|
||||
public UpdatePackageOperation UpdatePackageAsync(int resourceVersion, int timeout)
|
||||
{
|
||||
var operation = new HostPlayModeUpdatePackageOperation(this, resourceVersion, timeout);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
OperationSystem.StartOperaiton(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -182,29 +182,32 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 创建下载器
|
||||
/// </summary>
|
||||
public PatchDownloaderOperation CreatePatchDownloaderByPaths(List<string> assetPaths, int fileLoadingMaxNumber, int failedTryAgain)
|
||||
public PatchDownloaderOperation CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int fileLoadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByPaths(assetPaths);
|
||||
List<BundleInfo> downloadList = GetDownloadListByPaths(assetInfos);
|
||||
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
private List<BundleInfo> GetDownloadListByPaths(List<string> assetPaths)
|
||||
private List<BundleInfo> GetDownloadListByPaths(AssetInfo[] assetInfos)
|
||||
{
|
||||
// 获取资源对象的资源包和所有依赖资源包
|
||||
List<PatchBundle> checkList = new List<PatchBundle>();
|
||||
foreach (var assetPath in assetPaths)
|
||||
foreach (var assetInfo in assetInfos)
|
||||
{
|
||||
string mainBundleName = LocalPatchManifest.GetBundleName(assetPath);
|
||||
if (string.IsNullOrEmpty(mainBundleName) == false)
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
if (LocalPatchManifest.Bundles.TryGetValue(mainBundleName, out PatchBundle mainBundle))
|
||||
{
|
||||
if (checkList.Contains(mainBundle) == false)
|
||||
checkList.Add(mainBundle);
|
||||
}
|
||||
YooLogger.Warning(assetInfo.Error);
|
||||
continue;
|
||||
}
|
||||
|
||||
string[] dependBundleNames = LocalPatchManifest.GetAllDependencies(assetPath);
|
||||
string mainBundleName = LocalPatchManifest.GetBundleName(assetInfo.AssetPath);
|
||||
if (LocalPatchManifest.Bundles.TryGetValue(mainBundleName, out PatchBundle mainBundle))
|
||||
{
|
||||
if (checkList.Contains(mainBundle) == false)
|
||||
checkList.Add(mainBundle);
|
||||
}
|
||||
|
||||
string[] dependBundleNames = LocalPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
foreach (var dependBundleName in dependBundleNames)
|
||||
{
|
||||
if (LocalPatchManifest.Bundles.TryGetValue(dependBundleName, out PatchBundle dependBundle))
|
||||
@@ -245,6 +248,12 @@ namespace YooAsset
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByAll(AppPatchManifest);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
|
||||
// WEB相关
|
||||
public string GetPatchDownloadMainURL(string fileName)
|
||||
@@ -288,11 +297,8 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
#region IBundleServices接口
|
||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||
private BundleInfo CreateBundleInfo(string bundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
return new BundleInfo(string.Empty);
|
||||
|
||||
if (LocalPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||
{
|
||||
// 查询沙盒资源
|
||||
@@ -317,31 +323,46 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
||||
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||
return bundleInfo;
|
||||
throw new Exception("Should never get here !");
|
||||
}
|
||||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string bundleName)
|
||||
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
return PatchHelper.GetAssetsInfoByBundleName(LocalPatchManifest, bundleName);
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
string bundleName = LocalPatchManifest.GetBundleName(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(bundleName);
|
||||
}
|
||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
var depends = LocalPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||
foreach (var bundleName in depends)
|
||||
{
|
||||
BundleInfo bundleInfo = CreateBundleInfo(bundleName);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||
{
|
||||
return PatchHelper.GetAssetsInfoByTags(LocalPatchManifest, tags);
|
||||
}
|
||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||
{
|
||||
if (LocalPatchManifest.Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
||||
return patchAsset;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return LocalPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetBundleName(string assetPath)
|
||||
{
|
||||
return LocalPatchManifest.GetBundleName(assetPath);
|
||||
}
|
||||
string[] IBundleServices.GetAllDependencies(string assetPath)
|
||||
{
|
||||
return LocalPatchManifest.GetAllDependencies(assetPath);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ namespace YooAsset
|
||||
{
|
||||
_locationToLower = locationToLower;
|
||||
var operation = new OfflinePlayModeInitializationOperation(this);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
OperationSystem.StartOperaiton(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,12 @@ namespace YooAsset
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByAll(_appPatchManifest);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 设置资源清单
|
||||
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||
@@ -48,11 +54,8 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
#region IBundleServices接口
|
||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||
private BundleInfo CreateBundleInfo(string bundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
return new BundleInfo(string.Empty);
|
||||
|
||||
if (_appPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
||||
@@ -60,31 +63,46 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
||||
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||
return bundleInfo;
|
||||
throw new Exception("Should never get here !");
|
||||
}
|
||||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string bundleName)
|
||||
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
return PatchHelper.GetAssetsInfoByBundleName(_appPatchManifest, bundleName);
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
string bundleName = _appPatchManifest.GetBundleName(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(bundleName);
|
||||
}
|
||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
var depends = _appPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||
foreach (var bundleName in depends)
|
||||
{
|
||||
BundleInfo bundleInfo = CreateBundleInfo(bundleName);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||
{
|
||||
return PatchHelper.GetAssetsInfoByTags(_appPatchManifest, tags);
|
||||
}
|
||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||
{
|
||||
if (_appPatchManifest.Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
||||
return patchAsset;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return _appPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetBundleName(string assetPath)
|
||||
{
|
||||
return _appPatchManifest.GetBundleName(assetPath);
|
||||
}
|
||||
string[] IBundleServices.GetAllDependencies(string assetPath)
|
||||
{
|
||||
return _appPatchManifest.GetAllDependencies(assetPath);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user