mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-15 04:00:16 +00:00
Assetbundle加载增加解密方法
This commit is contained in:
@@ -97,6 +97,11 @@ namespace YooAsset
|
||||
/// 自定义参数:断点续传下载器关注的错误码
|
||||
/// </summary>
|
||||
public List<long> ResumeDownloadResponseCodes { private set; get; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:解密方法类
|
||||
/// </summary>
|
||||
public IDecryptionServices DecryptionServices { private set; get; }
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -208,30 +213,34 @@ namespace YooAsset
|
||||
|
||||
public virtual void SetParameter(string name, object value)
|
||||
{
|
||||
if (name == "REMOTE_SERVICES")
|
||||
if (name == FileSystemParameters.REMOTE_SERVICES)
|
||||
{
|
||||
RemoteServices = (IRemoteServices)value;
|
||||
}
|
||||
else if (name == "FILE_VERIFY_LEVEL")
|
||||
else if (name == FileSystemParameters.FILE_VERIFY_LEVEL)
|
||||
{
|
||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||
}
|
||||
else if (name == "APPEND_FILE_EXTENSION")
|
||||
else if (name == FileSystemParameters.APPEND_FILE_EXTENSION)
|
||||
{
|
||||
AppendFileExtension = (bool)value;
|
||||
}
|
||||
else if (name == "RAW_FILE_BUILD_PIPELINE")
|
||||
else if (name == FileSystemParameters.RAW_FILE_BUILD_PIPELINE)
|
||||
{
|
||||
RawFileBuildPipeline = (bool)value;
|
||||
}
|
||||
else if (name == "RESUME_DOWNLOAD_MINMUM_SIZE")
|
||||
else if (name == FileSystemParameters.RESUME_DOWNLOAD_MINMUM_SIZE)
|
||||
{
|
||||
ResumeDownloadMinimumSize = (long)value;
|
||||
}
|
||||
else if (name == "RESUME_DOWNLOAD_RESPONSE_CODES")
|
||||
else if (name == FileSystemParameters.RESUME_DOWNLOAD_RESPONSE_CODES)
|
||||
{
|
||||
ResumeDownloadResponseCodes = (List<long>)value;
|
||||
}
|
||||
else if (name == FileSystemParameters.DECRYPTION_SERVICES)
|
||||
{
|
||||
DecryptionServices = (IDecryptionServices)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Invalid parameter : {name}");
|
||||
@@ -528,6 +537,60 @@ namespace YooAsset
|
||||
{
|
||||
return _wrappers.Keys.ToList();
|
||||
}
|
||||
|
||||
internal AssetBundle LoadAssetBundle(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetCacheFileLoadPath(bundle);
|
||||
|
||||
if (bundle.Encrypted)
|
||||
{
|
||||
if (DecryptionServices == null)
|
||||
{
|
||||
YooLogger.Error($"DecryptionServices is Null!");
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DecryptionServices.LoadAssetBundle(new DecryptFileInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
}, out _);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return AssetBundle.LoadFromFile(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
internal AssetBundleCreateRequest LoadAssetBundleAsync(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetCacheFileLoadPath(bundle);
|
||||
|
||||
if (bundle.Encrypted)
|
||||
{
|
||||
if (DecryptionServices == null)
|
||||
{
|
||||
YooLogger.Error($"DecryptionServices is Empty!");
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DecryptionServices.LoadAssetBundleAsync(new DecryptFileInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
}, out _);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return AssetBundle.LoadFromFileAsync(filePath);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user