mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-24 09:40:11 +00:00
优化了资源定位不正确导致的错误报告方式。 YooAssets.ProcessOperation()重命名为YooAssets.StartOperation() YooAssets.GetBundleInfo()已经移除方法。 YooAssets.IsNeedDownloadFromRemote()新增加方法。
78 lines
2.2 KiB
C#
78 lines
2.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace YooAsset
|
|
{
|
|
internal class EditorSimulateModeImpl : IBundleServices
|
|
{
|
|
private PatchManifest _simulatePatchManifest;
|
|
private bool _locationToLower;
|
|
|
|
/// <summary>
|
|
/// 异步初始化
|
|
/// </summary>
|
|
public InitializationOperation InitializeAsync(bool locationToLower, string simulatePatchManifestPath)
|
|
{
|
|
_locationToLower = locationToLower;
|
|
var operation = new EditorSimulateModeInitializationOperation(this, simulatePatchManifestPath);
|
|
OperationSystem.StartOperaiton(operation);
|
|
return operation;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取资源版本号
|
|
/// </summary>
|
|
public int GetResourceVersion()
|
|
{
|
|
if (_simulatePatchManifest == null)
|
|
return 0;
|
|
return _simulatePatchManifest.ResourceVersion;
|
|
}
|
|
|
|
// 设置资源清单
|
|
internal void SetSimulatePatchManifest(PatchManifest patchManifest)
|
|
{
|
|
_simulatePatchManifest = patchManifest;
|
|
_simulatePatchManifest.InitAssetPathMapping(_locationToLower);
|
|
}
|
|
|
|
#region IBundleServices接口
|
|
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
|
{
|
|
if(assetInfo.IsInvalid)
|
|
throw new Exception("Should never get here !");
|
|
|
|
string bundleName = _simulatePatchManifest.GetBundleName(assetInfo.AssetPath);
|
|
if (_simulatePatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
|
{
|
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath);
|
|
return bundleInfo;
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("Should never get here !");
|
|
}
|
|
}
|
|
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
|
{
|
|
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);
|
|
}
|
|
#endregion
|
|
}
|
|
} |