mirror of https://github.com/tuyoogame/YooAsset
update file system
parent
b151f968d7
commit
a9e5e7fdd3
|
@ -128,6 +128,44 @@ namespace YooAsset
|
||||||
string buidlinFilePath = GetBuildinFileLoadPath(bundle);
|
string buidlinFilePath = GetBuildinFileLoadPath(bundle);
|
||||||
return UnpackFileSystem.DownloadFileAsync(bundle, buidlinFilePath, failedTryAgain, timeout);
|
return UnpackFileSystem.DownloadFileAsync(bundle, buidlinFilePath, failedTryAgain, timeout);
|
||||||
}
|
}
|
||||||
|
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (RawFileBuildPipeline)
|
||||||
|
{
|
||||||
|
var operation = new DBFSLoadRawBundleOperation(this, bundle);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var operation = new DBFSLoadAssetBundleOperation(this, bundle);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
|
||||||
|
{
|
||||||
|
AssetBundle assetBundle = result as AssetBundle;
|
||||||
|
if (assetBundle == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (UnpackFileSystem.Exists(bundle))
|
||||||
|
{
|
||||||
|
UnpackFileSystem.UnloadBundleFile(bundle, assetBundle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (assetBundle != null)
|
||||||
|
assetBundle.Unload(true);
|
||||||
|
|
||||||
|
if (_loadedStream.TryGetValue(bundle.BundleGUID, out Stream managedStream))
|
||||||
|
{
|
||||||
|
managedStream.Close();
|
||||||
|
managedStream.Dispose();
|
||||||
|
_loadedStream.Remove(bundle.BundleGUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void SetParameter(string name, object value)
|
public virtual void SetParameter(string name, object value)
|
||||||
{
|
{
|
||||||
|
@ -170,26 +208,17 @@ namespace YooAsset
|
||||||
|
|
||||||
public virtual bool Belong(PackageBundle bundle)
|
public virtual bool Belong(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
return Belong(bundle.BundleGUID);
|
return _wrappers.ContainsKey(bundle.BundleGUID);
|
||||||
}
|
|
||||||
public virtual bool Belong(string bundleGUID)
|
|
||||||
{
|
|
||||||
return _wrappers.ContainsKey(bundleGUID);
|
|
||||||
}
|
}
|
||||||
public virtual bool Exists(PackageBundle bundle)
|
public virtual bool Exists(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
return Exists(bundle.BundleGUID);
|
return _wrappers.ContainsKey(bundle.BundleGUID);
|
||||||
}
|
}
|
||||||
public virtual bool Exists(string bundleGUID)
|
public virtual bool NeedDownload(PackageBundle bundle)
|
||||||
{
|
|
||||||
return _wrappers.ContainsKey(bundleGUID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CheckNeedDownload(PackageBundle bundle)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public virtual bool CheckNeedUnpack(PackageBundle bundle)
|
public virtual bool NeedUnpack(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
if (Belong(bundle) == false)
|
if (Belong(bundle) == false)
|
||||||
return false;
|
return false;
|
||||||
|
@ -200,76 +229,11 @@ namespace YooAsset
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
public virtual bool CheckNeedImport(PackageBundle bundle)
|
public virtual bool NeedImport(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool WriteFile(PackageBundle bundle, string copyPath)
|
|
||||||
{
|
|
||||||
return UnpackFileSystem.WriteFile(bundle, copyPath);
|
|
||||||
}
|
|
||||||
public virtual bool DeleteFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
return UnpackFileSystem.DeleteFile(bundle);
|
|
||||||
}
|
|
||||||
public virtual bool DeleteFile(string bundleGUID)
|
|
||||||
{
|
|
||||||
return UnpackFileSystem.DeleteFile(bundleGUID);
|
|
||||||
}
|
|
||||||
public virtual EFileVerifyResult VerifyFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
return UnpackFileSystem.VerifyFile(bundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual byte[] ReadFileBytes(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
public virtual string ReadFileText(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
if (RawFileBuildPipeline)
|
|
||||||
{
|
|
||||||
var operation = new DBFSLoadRawBundleOperation(this, bundle);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var operation = new DBFSLoadAssetBundleOperation(this, bundle);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
|
|
||||||
{
|
|
||||||
AssetBundle assetBundle = result as AssetBundle;
|
|
||||||
if (assetBundle == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (UnpackFileSystem.Exists(bundle))
|
|
||||||
{
|
|
||||||
UnpackFileSystem.UnloadBundleFile(bundle, assetBundle);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (assetBundle != null)
|
|
||||||
assetBundle.Unload(true);
|
|
||||||
|
|
||||||
if (_loadedStream.TryGetValue(bundle.BundleGUID, out Stream managedStream))
|
|
||||||
{
|
|
||||||
managedStream.Close();
|
|
||||||
managedStream.Dispose();
|
|
||||||
_loadedStream.Remove(bundle.BundleGUID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
protected string GetDefaultRoot()
|
protected string GetDefaultRoot()
|
||||||
{
|
{
|
||||||
|
@ -311,9 +275,9 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 记录缓存信息
|
/// 记录文件信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Record(string bundleGUID, FileWrapper wrapper)
|
public bool RecordFile(string bundleGUID, FileWrapper wrapper)
|
||||||
{
|
{
|
||||||
if (_wrappers.ContainsKey(bundleGUID))
|
if (_wrappers.ContainsKey(bundleGUID))
|
||||||
{
|
{
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace YooAsset
|
||||||
if (manifest.TryGetPackageBundleByFileName(fileName, out PackageBundle value))
|
if (manifest.TryGetPackageBundleByFileName(fileName, out PackageBundle value))
|
||||||
{
|
{
|
||||||
var fileWrapper = new DefaultBuildinFileSystem.FileWrapper(fileName);
|
var fileWrapper = new DefaultBuildinFileSystem.FileWrapper(fileName);
|
||||||
_fileSystem.Record(value.BundleGUID, fileWrapper);
|
_fileSystem.RecordFile(value.BundleGUID, fileWrapper);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace YooAsset
|
||||||
DownloadProgress = 1f;
|
DownloadProgress = 1f;
|
||||||
DownloadedBytes = _bundle.FileSize;
|
DownloadedBytes = _bundle.FileSize;
|
||||||
|
|
||||||
if (_fileSystem.CheckNeedUnpack(_bundle))
|
if (_fileSystem.NeedUnpack(_bundle))
|
||||||
{
|
{
|
||||||
_steps = ESteps.UnpackAssetBundleFile;
|
_steps = ESteps.UnpackAssetBundleFile;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ namespace YooAsset
|
||||||
DownloadProgress = 1f;
|
DownloadProgress = 1f;
|
||||||
DownloadedBytes = _bundle.FileSize;
|
DownloadedBytes = _bundle.FileSize;
|
||||||
|
|
||||||
if (_fileSystem.CheckNeedUnpack(_bundle))
|
if (_fileSystem.NeedUnpack(_bundle))
|
||||||
{
|
{
|
||||||
_steps = ESteps.UnpackRawBundleFile;
|
_steps = ESteps.UnpackRawBundleFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace YooAsset
|
||||||
foreach (var wrapper in catalog.Wrappers)
|
foreach (var wrapper in catalog.Wrappers)
|
||||||
{
|
{
|
||||||
var fileWrapper = new DefaultBuildinFileSystem.FileWrapper(wrapper.FileName);
|
var fileWrapper = new DefaultBuildinFileSystem.FileWrapper(wrapper.FileName);
|
||||||
_fileSystem.Record(wrapper.BundleGUID, fileWrapper);
|
_fileSystem.RecordFile(wrapper.BundleGUID, fileWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' catalog files count : {catalog.Wrappers.Count}");
|
YooLogger.Log($"Package '{_fileSystem.PackageName}' catalog files count : {catalog.Wrappers.Count}");
|
||||||
|
|
|
@ -197,6 +197,37 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (RawFileBuildPipeline)
|
||||||
|
{
|
||||||
|
var operation = new DCFSLoadRawBundleOperation(this, bundle);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var operation = new DCFSLoadAssetBundleOperation(this, bundle);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
|
||||||
|
{
|
||||||
|
AssetBundle assetBundle = result as AssetBundle;
|
||||||
|
if (assetBundle == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (assetBundle != null)
|
||||||
|
assetBundle.Unload(true);
|
||||||
|
|
||||||
|
if (_loadedStream.TryGetValue(bundle.BundleGUID, out Stream managedStream))
|
||||||
|
{
|
||||||
|
managedStream.Close();
|
||||||
|
managedStream.Dispose();
|
||||||
|
_loadedStream.Remove(bundle.BundleGUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void SetParameter(string name, object value)
|
public virtual void SetParameter(string name, object value)
|
||||||
{
|
{
|
||||||
|
@ -268,35 +299,26 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Belong(PackageBundle bundle)
|
public virtual bool Belong(PackageBundle bundle)
|
||||||
{
|
|
||||||
return Belong(bundle.BundleGUID);
|
|
||||||
}
|
|
||||||
public virtual bool Belong(string bundleGUID)
|
|
||||||
{
|
{
|
||||||
// 注意:缓存文件系统保底加载!
|
// 注意:缓存文件系统保底加载!
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public virtual bool Exists(PackageBundle bundle)
|
public virtual bool Exists(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
return Exists(bundle.BundleGUID);
|
return _wrappers.ContainsKey(bundle.BundleGUID);
|
||||||
}
|
}
|
||||||
public virtual bool Exists(string bundleGUID)
|
public virtual bool NeedDownload(PackageBundle bundle)
|
||||||
{
|
|
||||||
return _wrappers.ContainsKey(bundleGUID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CheckNeedDownload(PackageBundle bundle)
|
|
||||||
{
|
{
|
||||||
if (Belong(bundle) == false)
|
if (Belong(bundle) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Exists(bundle) == false;
|
return Exists(bundle) == false;
|
||||||
}
|
}
|
||||||
public virtual bool CheckNeedUnpack(PackageBundle bundle)
|
public virtual bool NeedUnpack(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public virtual bool CheckNeedImport(PackageBundle bundle)
|
public virtual bool NeedImport(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
if (Belong(bundle) == false)
|
if (Belong(bundle) == false)
|
||||||
return false;
|
return false;
|
||||||
|
@ -304,119 +326,6 @@ namespace YooAsset
|
||||||
return Exists(bundle) == false;
|
return Exists(bundle) == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool WriteFile(PackageBundle bundle, string copyPath)
|
|
||||||
{
|
|
||||||
if (_wrappers.ContainsKey(bundle.BundleGUID))
|
|
||||||
{
|
|
||||||
throw new Exception("Should never get here !");
|
|
||||||
}
|
|
||||||
|
|
||||||
string infoFilePath = GetInfoFilePath(bundle);
|
|
||||||
string dataFilePath = GetDataFilePath(bundle);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (File.Exists(infoFilePath))
|
|
||||||
File.Delete(infoFilePath);
|
|
||||||
if (File.Exists(dataFilePath))
|
|
||||||
File.Delete(dataFilePath);
|
|
||||||
|
|
||||||
FileUtility.CreateFileDirectory(dataFilePath);
|
|
||||||
|
|
||||||
// 拷贝数据文件
|
|
||||||
FileInfo fileInfo = new FileInfo(copyPath);
|
|
||||||
fileInfo.CopyTo(dataFilePath);
|
|
||||||
|
|
||||||
// 写入文件信息
|
|
||||||
WriteInfoFile(infoFilePath, bundle.FileCRC, bundle.FileSize);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
YooLogger.Error($"Failed to write cache file ! {e.Message}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileWrapper wrapper = new FileWrapper(infoFilePath, dataFilePath, bundle.FileCRC, bundle.FileSize);
|
|
||||||
return Record(bundle.BundleGUID, wrapper);
|
|
||||||
}
|
|
||||||
public virtual bool DeleteFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
return DeleteFile(bundle.BundleGUID);
|
|
||||||
}
|
|
||||||
public virtual bool DeleteFile(string bundleGUID)
|
|
||||||
{
|
|
||||||
if (_wrappers.TryGetValue(bundleGUID, out FileWrapper wrapper))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string dataFilePath = wrapper.DataFilePath;
|
|
||||||
FileInfo fileInfo = new FileInfo(dataFilePath);
|
|
||||||
if (fileInfo.Exists)
|
|
||||||
fileInfo.Directory.Delete(true);
|
|
||||||
_wrappers.Remove(bundleGUID);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
YooLogger.Error($"Failed to delete cache file ! {e.Message}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public virtual EFileVerifyResult VerifyFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
if (_wrappers.TryGetValue(bundle.BundleGUID, out FileWrapper wrapper) == false)
|
|
||||||
return EFileVerifyResult.CacheNotFound;
|
|
||||||
|
|
||||||
EFileVerifyResult result = FileSystemHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual byte[] ReadFileBytes(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
public virtual string ReadFileText(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
if (RawFileBuildPipeline)
|
|
||||||
{
|
|
||||||
var operation = new DCFSLoadRawBundleOperation(this, bundle);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var operation = new DCFSLoadAssetBundleOperation(this, bundle);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
|
|
||||||
{
|
|
||||||
AssetBundle assetBundle = result as AssetBundle;
|
|
||||||
if (assetBundle == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (assetBundle != null)
|
|
||||||
assetBundle.Unload(true);
|
|
||||||
|
|
||||||
if (_loadedStream.TryGetValue(bundle.BundleGUID, out Stream managedStream))
|
|
||||||
{
|
|
||||||
managedStream.Close();
|
|
||||||
managedStream.Dispose();
|
|
||||||
_loadedStream.Remove(bundle.BundleGUID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
private readonly BufferWriter _sharedBuffer = new BufferWriter(1024);
|
private readonly BufferWriter _sharedBuffer = new BufferWriter(1024);
|
||||||
public void WriteInfoFile(string filePath, string dataFileCRC, long dataFileSize)
|
public void WriteInfoFile(string filePath, string dataFileCRC, long dataFileSize)
|
||||||
|
@ -504,24 +413,21 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
return PathUtility.Combine(_manifestFileRoot, DefaultCacheFileSystemDefine.AppFootPrintFileName);
|
return PathUtility.Combine(_manifestFileRoot, DefaultCacheFileSystemDefine.AppFootPrintFileName);
|
||||||
}
|
}
|
||||||
public void DeleteAllManifestFiles()
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否已经记录了文件
|
||||||
|
/// </summary>
|
||||||
|
public bool IsRecordFile(string bundleGUID)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(_manifestFileRoot))
|
return _wrappers.ContainsKey(bundleGUID);
|
||||||
{
|
|
||||||
Directory.Delete(_manifestFileRoot, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public List<string> GetAllCachedBundleGUIDs()
|
|
||||||
{
|
|
||||||
return _wrappers.Keys.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 记录缓存信息
|
/// 记录文件信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Record(string bundleGUID, FileWrapper wrapper)
|
public bool RecordFile(string bundleGUID, FileWrapper wrapper)
|
||||||
{
|
{
|
||||||
if (Exists(bundleGUID))
|
if (_wrappers.ContainsKey(bundleGUID))
|
||||||
{
|
{
|
||||||
YooLogger.Error($"{nameof(DefaultCacheFileSystem)} has element : {bundleGUID}");
|
YooLogger.Error($"{nameof(DefaultCacheFileSystem)} has element : {bundleGUID}");
|
||||||
return false;
|
return false;
|
||||||
|
@ -530,6 +436,104 @@ namespace YooAsset
|
||||||
_wrappers.Add(bundleGUID, wrapper);
|
_wrappers.Add(bundleGUID, wrapper);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证缓存文件
|
||||||
|
/// </summary>
|
||||||
|
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (_wrappers.TryGetValue(bundle.BundleGUID, out FileWrapper wrapper) == false)
|
||||||
|
return EFileVerifyResult.CacheNotFound;
|
||||||
|
|
||||||
|
EFileVerifyResult result = FileSystemHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写入缓存文件
|
||||||
|
/// </summary>
|
||||||
|
public bool WriteCacheFile(PackageBundle bundle, string copyPath)
|
||||||
|
{
|
||||||
|
if (_wrappers.ContainsKey(bundle.BundleGUID))
|
||||||
|
{
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
}
|
||||||
|
|
||||||
|
string infoFilePath = GetInfoFilePath(bundle);
|
||||||
|
string dataFilePath = GetDataFilePath(bundle);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.Exists(infoFilePath))
|
||||||
|
File.Delete(infoFilePath);
|
||||||
|
if (File.Exists(dataFilePath))
|
||||||
|
File.Delete(dataFilePath);
|
||||||
|
|
||||||
|
FileUtility.CreateFileDirectory(dataFilePath);
|
||||||
|
|
||||||
|
// 拷贝数据文件
|
||||||
|
FileInfo fileInfo = new FileInfo(copyPath);
|
||||||
|
fileInfo.CopyTo(dataFilePath);
|
||||||
|
|
||||||
|
// 写入文件信息
|
||||||
|
WriteInfoFile(infoFilePath, bundle.FileCRC, bundle.FileSize);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
YooLogger.Error($"Failed to write cache file ! {e.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileWrapper wrapper = new FileWrapper(infoFilePath, dataFilePath, bundle.FileCRC, bundle.FileSize);
|
||||||
|
return RecordFile(bundle.BundleGUID, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除缓存文件
|
||||||
|
/// </summary>
|
||||||
|
public bool DeleteCacheFile(string bundleGUID)
|
||||||
|
{
|
||||||
|
if (_wrappers.TryGetValue(bundleGUID, out FileWrapper wrapper))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string dataFilePath = wrapper.DataFilePath;
|
||||||
|
FileInfo fileInfo = new FileInfo(dataFilePath);
|
||||||
|
if (fileInfo.Exists)
|
||||||
|
fileInfo.Directory.Delete(true);
|
||||||
|
_wrappers.Remove(bundleGUID);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
YooLogger.Error($"Failed to delete cache file ! {e.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除所有清单文件
|
||||||
|
/// </summary>
|
||||||
|
public void DeleteAllManifestFiles()
|
||||||
|
{
|
||||||
|
if (Directory.Exists(_manifestFileRoot))
|
||||||
|
{
|
||||||
|
Directory.Delete(_manifestFileRoot, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有缓存文件GUID
|
||||||
|
/// </summary>
|
||||||
|
public List<string> GetAllCachedBundleGUIDs()
|
||||||
|
{
|
||||||
|
return _wrappers.Keys.ToList();
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -45,7 +45,7 @@ namespace YooAsset
|
||||||
for (int i = _allBundleGUIDs.Count - 1; i >= 0; i--)
|
for (int i = _allBundleGUIDs.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
string bundleGUID = _allBundleGUIDs[i];
|
string bundleGUID = _allBundleGUIDs[i];
|
||||||
_fileSystem.DeleteFile(bundleGUID);
|
_fileSystem.DeleteCacheFile(bundleGUID);
|
||||||
_allBundleGUIDs.RemoveAt(i);
|
_allBundleGUIDs.RemoveAt(i);
|
||||||
if (OperationSystem.IsBusy)
|
if (OperationSystem.IsBusy)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace YooAsset
|
||||||
for (int i = _unusedBundleGUIDs.Count - 1; i >= 0; i--)
|
for (int i = _unusedBundleGUIDs.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
string bundleGUID = _unusedBundleGUIDs[i];
|
string bundleGUID = _unusedBundleGUIDs[i];
|
||||||
_fileSystem.DeleteFile(bundleGUID);
|
_fileSystem.DeleteCacheFile(bundleGUID);
|
||||||
_unusedBundleGUIDs.RemoveAt(i);
|
_unusedBundleGUIDs.RemoveAt(i);
|
||||||
if (OperationSystem.IsBusy)
|
if (OperationSystem.IsBusy)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -8,17 +8,18 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
private readonly DefaultCacheFileSystem _fileSystem;
|
private readonly DefaultCacheFileSystem _fileSystem;
|
||||||
private VerifyTempFileOperation _verifyOperation;
|
private VerifyTempFileOperation _verifyOperation;
|
||||||
private string _fileSavePath;
|
private string _tempFilePath;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal DCFSDownloadNormalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string mainURL, string fallbackURL, int failedTryAgain, int timeout)
|
internal DCFSDownloadNormalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle,
|
||||||
|
string mainURL, string fallbackURL, int failedTryAgain, int timeout)
|
||||||
: base(bundle, mainURL, fallbackURL, failedTryAgain, timeout)
|
: base(bundle, mainURL, fallbackURL, failedTryAgain, timeout)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
_fileSavePath = _fileSystem.GetTempFilePath(Bundle);
|
_tempFilePath = _fileSystem.GetTempFilePath(Bundle);
|
||||||
_steps = ESteps.CheckExists;
|
_steps = ESteps.CheckExists;
|
||||||
}
|
}
|
||||||
internal override void InternalOnUpdate()
|
internal override void InternalOnUpdate()
|
||||||
|
@ -43,26 +44,17 @@ namespace YooAsset
|
||||||
// 创建下载器
|
// 创建下载器
|
||||||
if (_steps == ESteps.CreateRequest)
|
if (_steps == ESteps.CreateRequest)
|
||||||
{
|
{
|
||||||
FileUtility.CreateFileDirectory(_fileSavePath);
|
FileUtility.CreateFileDirectory(_tempFilePath);
|
||||||
|
|
||||||
|
// 删除临时文件
|
||||||
|
if (File.Exists(_tempFilePath))
|
||||||
|
File.Delete(_tempFilePath);
|
||||||
|
|
||||||
// 获取请求地址
|
// 获取请求地址
|
||||||
_requestURL = GetRequestURL();
|
_requestURL = GetRequestURL();
|
||||||
|
|
||||||
// 重置变量
|
// 重置请求
|
||||||
_isAbort = false;
|
ResetRequestFiled();
|
||||||
_latestDownloadBytes = 0;
|
|
||||||
_latestDownloadRealtime = Time.realtimeSinceStartup;
|
|
||||||
DownloadProgress = 0f;
|
|
||||||
DownloadedBytes = 0;
|
|
||||||
|
|
||||||
// 重置计时器
|
|
||||||
if (_tryAgainTimer > 0f)
|
|
||||||
YooLogger.Warning($"Try again download : {_requestURL}");
|
|
||||||
_tryAgainTimer = 0f;
|
|
||||||
|
|
||||||
// 删除临时文件
|
|
||||||
if (File.Exists(_fileSavePath))
|
|
||||||
File.Delete(_fileSavePath);
|
|
||||||
|
|
||||||
// 创建下载器
|
// 创建下载器
|
||||||
CreateWebRequest();
|
CreateWebRequest();
|
||||||
|
@ -95,7 +87,7 @@ namespace YooAsset
|
||||||
// 验证下载文件
|
// 验证下载文件
|
||||||
if (_steps == ESteps.VerifyTempFile)
|
if (_steps == ESteps.VerifyTempFile)
|
||||||
{
|
{
|
||||||
var element = new TempFileElement(_fileSavePath, Bundle.FileCRC, Bundle.FileSize);
|
var element = new TempFileElement(_tempFilePath, Bundle.FileCRC, Bundle.FileSize);
|
||||||
_verifyOperation = new VerifyTempFileOperation(element);
|
_verifyOperation = new VerifyTempFileOperation(element);
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _verifyOperation);
|
OperationSystem.StartOperation(_fileSystem.PackageName, _verifyOperation);
|
||||||
_steps = ESteps.CheckVerifyTempFile;
|
_steps = ESteps.CheckVerifyTempFile;
|
||||||
|
@ -111,7 +103,7 @@ namespace YooAsset
|
||||||
|
|
||||||
if (_verifyOperation.Status == EOperationStatus.Succeed)
|
if (_verifyOperation.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
if (_fileSystem.WriteFile(Bundle, _fileSavePath))
|
if (_fileSystem.WriteCacheFile(Bundle, _tempFilePath))
|
||||||
{
|
{
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
|
@ -131,8 +123,8 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意:验证完成后直接删除文件
|
// 注意:验证完成后直接删除文件
|
||||||
if (File.Exists(_fileSavePath))
|
if (File.Exists(_tempFilePath))
|
||||||
File.Delete(_fileSavePath);
|
File.Delete(_tempFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新尝试下载
|
// 重新尝试下载
|
||||||
|
@ -183,7 +175,7 @@ namespace YooAsset
|
||||||
private void CreateWebRequest()
|
private void CreateWebRequest()
|
||||||
{
|
{
|
||||||
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
|
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
|
||||||
DownloadHandlerFile handler = new DownloadHandlerFile(_fileSavePath);
|
DownloadHandlerFile handler = new DownloadHandlerFile(_tempFilePath);
|
||||||
handler.removeFileOnAbort = true;
|
handler.removeFileOnAbort = true;
|
||||||
_webRequest.downloadHandler = handler;
|
_webRequest.downloadHandler = handler;
|
||||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||||
|
@ -210,7 +202,8 @@ namespace YooAsset
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
internal DCFSDownloadResumeFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string mainURL, string fallbackURL, int failedTryAgain, int timeout)
|
internal DCFSDownloadResumeFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle,
|
||||||
|
string mainURL, string fallbackURL, int failedTryAgain, int timeout)
|
||||||
: base(bundle, mainURL, fallbackURL, failedTryAgain, timeout)
|
: base(bundle, mainURL, fallbackURL, failedTryAgain, timeout)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
@ -248,19 +241,10 @@ namespace YooAsset
|
||||||
_requestURL = GetRequestURL();
|
_requestURL = GetRequestURL();
|
||||||
|
|
||||||
// 重置变量
|
// 重置变量
|
||||||
_isAbort = false;
|
ResetRequestFiled();
|
||||||
_latestDownloadBytes = 0;
|
|
||||||
_latestDownloadRealtime = Time.realtimeSinceStartup;
|
|
||||||
_fileOriginLength = 0;
|
|
||||||
DownloadProgress = 0f;
|
|
||||||
DownloadedBytes = 0;
|
|
||||||
|
|
||||||
// 重置计时器
|
|
||||||
if (_tryAgainTimer > 0f)
|
|
||||||
YooLogger.Warning($"Try again download : {_requestURL}");
|
|
||||||
_tryAgainTimer = 0f;
|
|
||||||
|
|
||||||
// 获取下载起始位置
|
// 获取下载起始位置
|
||||||
|
_fileOriginLength = 0;
|
||||||
long fileBeginLength = -1;
|
long fileBeginLength = -1;
|
||||||
if (File.Exists(_fileSavePath))
|
if (File.Exists(_fileSavePath))
|
||||||
{
|
{
|
||||||
|
@ -325,7 +309,7 @@ namespace YooAsset
|
||||||
|
|
||||||
if (_verifyOperation.Status == EOperationStatus.Succeed)
|
if (_verifyOperation.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
if (_fileSystem.WriteFile(Bundle, _fileSavePath))
|
if (_fileSystem.WriteCacheFile(Bundle, _fileSavePath))
|
||||||
{
|
{
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
if (_fileSystem.CheckNeedDownload(_bundle))
|
if (_fileSystem.NeedDownload(_bundle))
|
||||||
{
|
{
|
||||||
_steps = ESteps.DownloadFile;
|
_steps = ESteps.DownloadFile;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
// 注意:当缓存文件的校验等级为Low的时候,并不能保证缓存文件的完整性。
|
// 注意:当缓存文件的校验等级为Low的时候,并不能保证缓存文件的完整性。
|
||||||
// 说明:在AssetBundle文件加载失败的情况下,我们需要重新验证文件的完整性!
|
// 说明:在AssetBundle文件加载失败的情况下,我们需要重新验证文件的完整性!
|
||||||
EFileVerifyResult result = _fileSystem.VerifyFile(_bundle);
|
EFileVerifyResult result = _fileSystem.VerifyCacheFile(_bundle);
|
||||||
if (result == EFileVerifyResult.Succeed)
|
if (result == EFileVerifyResult.Succeed)
|
||||||
{
|
{
|
||||||
// 注意:在安卓移动平台,华为和三星真机上有极小概率加载资源包失败。
|
// 注意:在安卓移动平台,华为和三星真机上有极小概率加载资源包失败。
|
||||||
|
@ -146,7 +146,7 @@ namespace YooAsset
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
_fileSystem.DeleteFile(_bundle);
|
_fileSystem.DeleteCacheFile(_bundle.BundleGUID);
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Find corrupted file and delete the file : {_bundle.BundleName}";
|
Error = $"Find corrupted file and delete the file : {_bundle.BundleName}";
|
||||||
YooLogger.Error(Error);
|
YooLogger.Error(Error);
|
||||||
|
@ -215,7 +215,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
if (_fileSystem.CheckNeedDownload(_bundle))
|
if (_fileSystem.NeedDownload(_bundle))
|
||||||
{
|
{
|
||||||
_steps = ESteps.DownloadFile;
|
_steps = ESteps.DownloadFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace YooAsset
|
||||||
foreach (var chidDirectory in childDirectories)
|
foreach (var chidDirectory in childDirectories)
|
||||||
{
|
{
|
||||||
string bundleGUID = chidDirectory.Name;
|
string bundleGUID = chidDirectory.Name;
|
||||||
if (_fileSystem.Exists(bundleGUID))
|
if (_fileSystem.IsRecordFile(bundleGUID))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// 创建验证元素类
|
// 创建验证元素类
|
||||||
|
|
|
@ -159,7 +159,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
_succeedCount++;
|
_succeedCount++;
|
||||||
var fileWrapper = new DefaultCacheFileSystem.FileWrapper(element.InfoFilePath, element.DataFilePath, element.DataFileCRC, element.DataFileSize);
|
var fileWrapper = new DefaultCacheFileSystem.FileWrapper(element.InfoFilePath, element.DataFilePath, element.DataFileCRC, element.DataFileSize);
|
||||||
_fileSystem.Record(element.BundleGUID, fileWrapper);
|
_fileSystem.RecordFile(element.BundleGUID, fileWrapper);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置文件系统
|
/// 模拟文件系统
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class DefaultEditorFileSystem : IFileSystem
|
internal class DefaultEditorFileSystem : IFileSystem
|
||||||
{
|
{
|
||||||
|
@ -95,6 +91,15 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
var operation = new DEFSLoadBundleOperation(this, bundle);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void SetParameter(string name, object value)
|
public virtual void SetParameter(string name, object value)
|
||||||
{
|
{
|
||||||
|
@ -124,81 +129,28 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public virtual bool Belong(string bundleGUID)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public virtual bool Exists(PackageBundle bundle)
|
public virtual bool Exists(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public virtual bool Exists(string bundleGUID)
|
public virtual bool NeedDownload(PackageBundle bundle)
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CheckNeedDownload(PackageBundle bundle)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public virtual bool CheckNeedUnpack(PackageBundle bundle)
|
public virtual bool NeedUnpack(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public virtual bool CheckNeedImport(PackageBundle bundle)
|
public virtual bool NeedImport(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool WriteFile(PackageBundle bundle, string copyPath)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public virtual bool DeleteFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public virtual bool DeleteFile(string bundleGUID)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public virtual EFileVerifyResult VerifyFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
return EFileVerifyResult.Succeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual byte[] ReadFileBytes(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
public virtual string ReadFileText(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
var operation = new DEFSLoadBundleOperation(this, bundle);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
protected string GetDefaultRoot()
|
protected string GetDefaultRoot()
|
||||||
{
|
{
|
||||||
return "Assets/";
|
return "Assets/";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 记录缓存信息
|
|
||||||
/// </summary>
|
|
||||||
public bool Record(string bundleGUID, object value)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,6 +5,9 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Web文件系统
|
||||||
|
/// </summary>
|
||||||
internal class DefaultWebFileSystem : IFileSystem
|
internal class DefaultWebFileSystem : IFileSystem
|
||||||
{
|
{
|
||||||
public class FileWrapper
|
public class FileWrapper
|
||||||
|
@ -128,6 +131,21 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
var operation = new DWFSLoadAssetBundleOperation(this, bundle);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
|
||||||
|
{
|
||||||
|
AssetBundle assetBundle = result as AssetBundle;
|
||||||
|
if (assetBundle == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (assetBundle != null)
|
||||||
|
assetBundle.Unload(true);
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void SetParameter(string name, object value)
|
public virtual void SetParameter(string name, object value)
|
||||||
{
|
{
|
||||||
|
@ -165,74 +183,26 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public virtual bool Belong(string bundleGUID)
|
public virtual bool Exists(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public virtual bool Exists(PackageBundle bundle)
|
public virtual bool NeedDownload(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (Belong(bundle) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return Exists(bundle) == false;
|
||||||
|
}
|
||||||
|
public virtual bool NeedUnpack(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public virtual bool Exists(string bundleGUID)
|
public virtual bool NeedImport(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool CheckNeedDownload(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public virtual bool CheckNeedUnpack(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public virtual bool CheckNeedImport(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool WriteFile(PackageBundle bundle, string copyPath)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
public virtual bool DeleteFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
public virtual bool DeleteFile(string bundleGUID)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
public virtual EFileVerifyResult VerifyFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
return EFileVerifyResult.Succeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual byte[] ReadFileBytes(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
public virtual string ReadFileText(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
|
||||||
{
|
|
||||||
var operation = new DWFSLoadAssetBundleOperation(this, bundle);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
|
|
||||||
{
|
|
||||||
AssetBundle assetBundle = result as AssetBundle;
|
|
||||||
if (assetBundle == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (assetBundle != null)
|
|
||||||
assetBundle.Unload(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
protected string GetDefaultWebRoot()
|
protected string GetDefaultWebRoot()
|
||||||
{
|
{
|
||||||
|
@ -270,9 +240,9 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 记录缓存信息
|
/// 记录文件信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Record(string bundleGUID, FileWrapper wrapper)
|
public bool RecordFile(string bundleGUID, FileWrapper wrapper)
|
||||||
{
|
{
|
||||||
if (_wrappers.ContainsKey(bundleGUID))
|
if (_wrappers.ContainsKey(bundleGUID))
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,13 +7,12 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
DownloadFile,
|
DownloadFile,
|
||||||
CheckResult,
|
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultWebFileSystem _fileSystem;
|
private readonly DefaultWebFileSystem _fileSystem;
|
||||||
private readonly PackageBundle _bundle;
|
private readonly PackageBundle _bundle;
|
||||||
private DWFSDownloadWebFileOperation _downloadWebFileOp;
|
private DownloadHandlerAssetBundleOperation _downloadhanlderAssetBundleOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,32 +32,32 @@ namespace YooAsset
|
||||||
|
|
||||||
if (_steps == ESteps.DownloadFile)
|
if (_steps == ESteps.DownloadFile)
|
||||||
{
|
{
|
||||||
if (_downloadWebFileOp == null)
|
if (_downloadhanlderAssetBundleOp == null)
|
||||||
{
|
{
|
||||||
int failedTryAgain = int.MaxValue;
|
int failedTryAgain = int.MaxValue;
|
||||||
int timeout = 60;
|
int timeout = 60;
|
||||||
string mainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName);
|
string mainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName);
|
||||||
string fallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
string fallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
||||||
_downloadWebFileOp = new DWFSDownloadWebFileOperation(_fileSystem, _bundle, mainURL, fallbackURL, failedTryAgain, timeout);
|
_downloadhanlderAssetBundleOp = new DownloadHandlerAssetBundleOperation(_fileSystem, _bundle, mainURL, fallbackURL, failedTryAgain, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadProgress = _downloadWebFileOp.DownloadProgress;
|
DownloadProgress = _downloadhanlderAssetBundleOp.DownloadProgress;
|
||||||
DownloadedBytes = _downloadWebFileOp.DownloadedBytes;
|
DownloadedBytes = _downloadhanlderAssetBundleOp.DownloadedBytes;
|
||||||
Progress = _downloadWebFileOp.Progress;
|
Progress = _downloadhanlderAssetBundleOp.Progress;
|
||||||
if (_downloadWebFileOp.IsDone == false)
|
if (_downloadhanlderAssetBundleOp.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_downloadWebFileOp.Status == EOperationStatus.Succeed)
|
if (_downloadhanlderAssetBundleOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Result = _downloadWebFileOp.Result;
|
Result = _downloadhanlderAssetBundleOp.Result;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _downloadWebFileOp.Error;
|
Error = _downloadhanlderAssetBundleOp.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,8 +76,8 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.DownloadFile)
|
if (_steps == ESteps.DownloadFile)
|
||||||
{
|
{
|
||||||
if (_downloadWebFileOp != null)
|
if (_downloadhanlderAssetBundleOp != null)
|
||||||
_downloadWebFileOp.SetAbort();
|
_downloadhanlderAssetBundleOp.SetAbort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
using System.IO;
|
using UnityEngine;
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class DWFSDownloadWebFileOperation : DefaultDownloadFileOperation
|
internal class DownloadHandlerAssetBundleOperation : DefaultDownloadFileOperation
|
||||||
{
|
{
|
||||||
private readonly DefaultWebFileSystem _fileSystem;
|
private readonly DefaultWebFileSystem _fileSystem;
|
||||||
private DownloadHandlerAssetBundle _downloadhandler;
|
private DownloadHandlerAssetBundle _downloadhandler;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 下载结果
|
|
||||||
/// </summary>
|
|
||||||
public AssetBundle Result { private set; get; }
|
public AssetBundle Result { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
internal DWFSDownloadWebFileOperation(DefaultWebFileSystem fileSystem, PackageBundle bundle, string mainURL, string fallbackURL, int failedTryAgain, int timeout)
|
internal DownloadHandlerAssetBundleOperation(DefaultWebFileSystem fileSystem, PackageBundle bundle,
|
||||||
|
string mainURL, string fallbackURL, int failedTryAgain, int timeout)
|
||||||
: base(bundle, mainURL, fallbackURL, failedTryAgain, timeout)
|
: base(bundle, mainURL, fallbackURL, failedTryAgain, timeout)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
@ -37,16 +34,7 @@ namespace YooAsset
|
||||||
_requestURL = GetRequestURL();
|
_requestURL = GetRequestURL();
|
||||||
|
|
||||||
// 重置变量
|
// 重置变量
|
||||||
_isAbort = false;
|
ResetRequestFiled();
|
||||||
_latestDownloadBytes = 0;
|
|
||||||
_latestDownloadRealtime = Time.realtimeSinceStartup;
|
|
||||||
DownloadProgress = 0f;
|
|
||||||
DownloadedBytes = 0;
|
|
||||||
|
|
||||||
// 重置计时器
|
|
||||||
if (_tryAgainTimer > 0f)
|
|
||||||
YooLogger.Warning($"Try again download : {_requestURL}");
|
|
||||||
_tryAgainTimer = 0f;
|
|
||||||
|
|
||||||
// 创建下载器
|
// 创建下载器
|
||||||
CreateWebRequest();
|
CreateWebRequest();
|
||||||
|
@ -110,11 +98,21 @@ namespace YooAsset
|
||||||
|
|
||||||
private void CreateWebRequest()
|
private void CreateWebRequest()
|
||||||
{
|
{
|
||||||
|
_downloadhandler = CreateDownloadHandler();
|
||||||
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
|
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
|
||||||
_webRequest.downloadHandler = CreateDownloadHandler();
|
_webRequest.downloadHandler = _downloadhandler;
|
||||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||||
_webRequest.SendWebRequest();
|
_webRequest.SendWebRequest();
|
||||||
}
|
}
|
||||||
|
private void DisposeWebRequest()
|
||||||
|
{
|
||||||
|
if (_webRequest != null)
|
||||||
|
{
|
||||||
|
//注意:引擎底层会自动调用Abort方法
|
||||||
|
_webRequest.Dispose();
|
||||||
|
_webRequest = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
private DownloadHandlerAssetBundle CreateDownloadHandler()
|
private DownloadHandlerAssetBundle CreateDownloadHandler()
|
||||||
{
|
{
|
||||||
if (_fileSystem.DisableUnityWebCache)
|
if (_fileSystem.DisableUnityWebCache)
|
||||||
|
@ -138,14 +136,5 @@ namespace YooAsset
|
||||||
return downloadhandler;
|
return downloadhandler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void DisposeWebRequest()
|
|
||||||
{
|
|
||||||
if (_webRequest != null)
|
|
||||||
{
|
|
||||||
//注意:引擎底层会自动调用Abort方法
|
|
||||||
_webRequest.Dispose();
|
|
||||||
_webRequest = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -60,7 +60,7 @@ namespace YooAsset
|
||||||
foreach (var wrapper in catalog.Wrappers)
|
foreach (var wrapper in catalog.Wrappers)
|
||||||
{
|
{
|
||||||
var fileWrapper = new DefaultWebFileSystem.FileWrapper(wrapper.FileName);
|
var fileWrapper = new DefaultWebFileSystem.FileWrapper(wrapper.FileName);
|
||||||
_fileSystem.Record(wrapper.BundleGUID, fileWrapper);
|
_fileSystem.RecordFile(wrapper.BundleGUID, fileWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' catalog files count : {catalog.Wrappers.Count}");
|
YooLogger.Log($"Package '{_fileSystem.PackageName}' catalog files count : {catalog.Wrappers.Count}");
|
||||||
|
|
|
@ -54,6 +54,16 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
FSDownloadFileOperation DownloadFileAsync(params object[] args);
|
FSDownloadFileOperation DownloadFileAsync(params object[] args);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载Bundle文件
|
||||||
|
/// </summary>
|
||||||
|
FSLoadBundleOperation LoadBundleFile(PackageBundle bundle);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 卸载Bundle文件
|
||||||
|
/// </summary>
|
||||||
|
void UnloadBundleFile(PackageBundle bundle, object result);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置自定义参数
|
/// 设置自定义参数
|
||||||
|
@ -76,78 +86,24 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool Belong(PackageBundle bundle);
|
bool Belong(PackageBundle bundle);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询文件归属
|
|
||||||
/// </summary>
|
|
||||||
bool Belong(string bundleGUID);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询文件是否存在
|
/// 查询文件是否存在
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool Exists(PackageBundle bundle);
|
bool Exists(PackageBundle bundle);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询文件是否存在
|
/// 是否需要下载
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool Exists(string bundleGUID);
|
bool NeedDownload(PackageBundle bundle);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测是否需要下载
|
/// 是否需要解压
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool CheckNeedDownload(PackageBundle bundle);
|
bool NeedUnpack(PackageBundle bundle);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测是否需要解压
|
/// 是否需要导入
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool CheckNeedUnpack(PackageBundle bundle);
|
bool NeedImport(PackageBundle bundle);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检测是否需要导入
|
|
||||||
/// </summary>
|
|
||||||
bool CheckNeedImport(PackageBundle bundle);
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 写入文件
|
|
||||||
/// </summary>
|
|
||||||
bool WriteFile(PackageBundle bundle, string copyPath);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除文件
|
|
||||||
/// </summary>
|
|
||||||
bool DeleteFile(PackageBundle bundle);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除文件
|
|
||||||
/// </summary>
|
|
||||||
bool DeleteFile(string bundleGUID);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 校验文件
|
|
||||||
/// </summary>
|
|
||||||
EFileVerifyResult VerifyFile(PackageBundle bundle);
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 读取文件的二进制数据
|
|
||||||
/// </summary>
|
|
||||||
byte[] ReadFileBytes(PackageBundle bundle);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 读取文件的文本数据
|
|
||||||
/// </summary>
|
|
||||||
string ReadFileText(PackageBundle bundle);
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载Bundle文件
|
|
||||||
/// </summary>
|
|
||||||
FSLoadBundleOperation LoadBundleFile(PackageBundle bundle);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 卸载Bundle文件
|
|
||||||
/// </summary>
|
|
||||||
void UnloadBundleFile(PackageBundle bundle, object result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using UnityEngine.Networking;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -61,6 +62,24 @@ namespace YooAsset
|
||||||
return _mainURL;
|
return _mainURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重置请求字段
|
||||||
|
/// </summary>
|
||||||
|
protected void ResetRequestFiled()
|
||||||
|
{
|
||||||
|
// 重置变量
|
||||||
|
_isAbort = false;
|
||||||
|
_latestDownloadBytes = 0;
|
||||||
|
_latestDownloadRealtime = Time.realtimeSinceStartup;
|
||||||
|
DownloadProgress = 0f;
|
||||||
|
DownloadedBytes = 0;
|
||||||
|
|
||||||
|
// 重置计时器
|
||||||
|
if (_tryAgainTimer > 0f)
|
||||||
|
YooLogger.Warning($"Try again download : {_requestURL}");
|
||||||
|
_tryAgainTimer = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测请求超时
|
/// 检测请求超时
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsNeedDownloadFromRemote()
|
public bool IsNeedDownloadFromRemote()
|
||||||
{
|
{
|
||||||
return _fileSystem.CheckNeedDownload(Bundle);
|
return _fileSystem.NeedDownload(Bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -37,17 +37,17 @@ namespace YooAsset
|
||||||
IFileSystem fileSystem = null;
|
IFileSystem fileSystem = null;
|
||||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemA.CheckNeedDownload(packageBundle))
|
if (fileSystemA.NeedDownload(packageBundle))
|
||||||
fileSystem = fileSystemA;
|
fileSystem = fileSystemA;
|
||||||
}
|
}
|
||||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemB.CheckNeedDownload(packageBundle))
|
if (fileSystemB.NeedDownload(packageBundle))
|
||||||
fileSystem = fileSystemB;
|
fileSystem = fileSystemB;
|
||||||
}
|
}
|
||||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemC.CheckNeedDownload(packageBundle))
|
if (fileSystemC.NeedDownload(packageBundle))
|
||||||
fileSystem = fileSystemC;
|
fileSystem = fileSystemC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -70,17 +70,17 @@ namespace YooAsset
|
||||||
IFileSystem fileSystem = null;
|
IFileSystem fileSystem = null;
|
||||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemA.CheckNeedDownload(packageBundle))
|
if (fileSystemA.NeedDownload(packageBundle))
|
||||||
fileSystem = fileSystemA;
|
fileSystem = fileSystemA;
|
||||||
}
|
}
|
||||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemB.CheckNeedDownload(packageBundle))
|
if (fileSystemB.NeedDownload(packageBundle))
|
||||||
fileSystem = fileSystemB;
|
fileSystem = fileSystemB;
|
||||||
}
|
}
|
||||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemC.CheckNeedDownload(packageBundle))
|
if (fileSystemC.NeedDownload(packageBundle))
|
||||||
fileSystem = fileSystemC;
|
fileSystem = fileSystemC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -140,17 +140,17 @@ namespace YooAsset
|
||||||
IFileSystem fileSystem = null;
|
IFileSystem fileSystem = null;
|
||||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemA.CheckNeedDownload(packageBundle))
|
if (fileSystemA.NeedDownload(packageBundle))
|
||||||
fileSystem = fileSystemA;
|
fileSystem = fileSystemA;
|
||||||
}
|
}
|
||||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemB.CheckNeedDownload(packageBundle))
|
if (fileSystemB.NeedDownload(packageBundle))
|
||||||
fileSystem = fileSystemB;
|
fileSystem = fileSystemB;
|
||||||
}
|
}
|
||||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemC.CheckNeedDownload(packageBundle))
|
if (fileSystemC.NeedDownload(packageBundle))
|
||||||
fileSystem = fileSystemC;
|
fileSystem = fileSystemC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -173,17 +173,17 @@ namespace YooAsset
|
||||||
IFileSystem fileSystem = null;
|
IFileSystem fileSystem = null;
|
||||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemA.CheckNeedUnpack(packageBundle))
|
if (fileSystemA.NeedUnpack(packageBundle))
|
||||||
fileSystem = fileSystemA;
|
fileSystem = fileSystemA;
|
||||||
}
|
}
|
||||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemB.CheckNeedUnpack(packageBundle))
|
if (fileSystemB.NeedUnpack(packageBundle))
|
||||||
fileSystem = fileSystemB;
|
fileSystem = fileSystemB;
|
||||||
}
|
}
|
||||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemC.CheckNeedUnpack(packageBundle))
|
if (fileSystemC.NeedUnpack(packageBundle))
|
||||||
fileSystem = fileSystemC;
|
fileSystem = fileSystemC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -207,17 +207,17 @@ namespace YooAsset
|
||||||
IFileSystem fileSystem = null;
|
IFileSystem fileSystem = null;
|
||||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemA.CheckNeedUnpack(packageBundle))
|
if (fileSystemA.NeedUnpack(packageBundle))
|
||||||
fileSystem = fileSystemA;
|
fileSystem = fileSystemA;
|
||||||
}
|
}
|
||||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemB.CheckNeedUnpack(packageBundle))
|
if (fileSystemB.NeedUnpack(packageBundle))
|
||||||
fileSystem = fileSystemB;
|
fileSystem = fileSystemB;
|
||||||
}
|
}
|
||||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemC.CheckNeedUnpack(packageBundle))
|
if (fileSystemC.NeedUnpack(packageBundle))
|
||||||
fileSystem = fileSystemC;
|
fileSystem = fileSystemC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -248,17 +248,17 @@ namespace YooAsset
|
||||||
IFileSystem fileSystem = null;
|
IFileSystem fileSystem = null;
|
||||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemA.CheckNeedImport(packageBundle))
|
if (fileSystemA.NeedImport(packageBundle))
|
||||||
fileSystem = fileSystemA;
|
fileSystem = fileSystemA;
|
||||||
}
|
}
|
||||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemB.CheckNeedImport(packageBundle))
|
if (fileSystemB.NeedImport(packageBundle))
|
||||||
fileSystem = fileSystemB;
|
fileSystem = fileSystemB;
|
||||||
}
|
}
|
||||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
if (fileSystemC.CheckNeedImport(packageBundle))
|
if (fileSystemC.NeedImport(packageBundle))
|
||||||
fileSystem = fileSystemC;
|
fileSystem = fileSystemC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue