mirror of https://github.com/tuyoogame/YooAsset
Compare commits
No commits in common. "b0dc829b04d7d33cb0fb7e3131c1a4d8fd87e978" and "3f786bca3b267f08ecec6c22fb0b0eb3c423c105" have entirely different histories.
b0dc829b04
...
3f786bca3b
|
@ -58,11 +58,6 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:覆盖安装缓存清理模式
|
||||
/// </summary>
|
||||
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:数据文件追加文件格式
|
||||
/// </summary>
|
||||
|
@ -150,10 +145,6 @@ namespace YooAsset
|
|||
{
|
||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||
{
|
||||
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||
{
|
||||
AppendFileExtension = Convert.ToBoolean(value);
|
||||
|
@ -193,7 +184,6 @@ namespace YooAsset
|
|||
_unpackFileSystem = new DefaultUnpackFileSystem();
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.INSTALL_CLEAR_MODE, InstallClearMode);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, AppendFileExtension);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
|
||||
_unpackFileSystem.OnCreate(packageName, null);
|
||||
|
|
|
@ -69,7 +69,8 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||
string fileHash = HashUtility.BytesCRC32(_webDataRequestOp.Result);
|
||||
if (fileHash == _packageHash)
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
|
|
|
@ -65,11 +65,6 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:覆盖安装缓存清理模式
|
||||
/// </summary>
|
||||
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:数据文件追加文件格式
|
||||
/// </summary>
|
||||
|
@ -193,10 +188,6 @@ namespace YooAsset
|
|||
{
|
||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||
{
|
||||
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||
{
|
||||
AppendFileExtension = Convert.ToBoolean(value);
|
||||
|
@ -236,8 +227,8 @@ namespace YooAsset
|
|||
_packageRoot = packageRoot;
|
||||
|
||||
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.BundleFilesFolderName);
|
||||
_cacheManifestFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
||||
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName);
|
||||
_cacheManifestFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
||||
}
|
||||
public virtual void OnDestroy()
|
||||
{
|
||||
|
@ -509,18 +500,7 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除所有缓存的资源文件
|
||||
/// </summary>
|
||||
public void DeleteAllBundleFiles()
|
||||
{
|
||||
if (Directory.Exists(_cacheBundleFilesRoot))
|
||||
{
|
||||
Directory.Delete(_cacheBundleFilesRoot, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除所有缓存的清单文件
|
||||
/// 删除所有清单文件
|
||||
/// </summary>
|
||||
public void DeleteAllManifestFiles()
|
||||
{
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 覆盖安装清理模式
|
||||
/// </summary>
|
||||
public enum EOverwriteInstallClearMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 不做任何处理
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有缓存文件(包含资源文件和清单文件)
|
||||
/// </summary>
|
||||
ClearAllCacheFiles = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有缓存的资源文件
|
||||
/// </summary>
|
||||
ClearAllBundleFiles = 2,
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有缓存的清单文件
|
||||
/// </summary>
|
||||
ClearAllManifestFiles = 3,
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c61fdc079dca97548a0158b8100ec258
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -46,32 +46,9 @@ namespace YooAsset
|
|||
// 如果水印发生变化,则说明覆盖安装后首次打开游戏
|
||||
if (appFootPrint.IsDirty())
|
||||
{
|
||||
if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.None)
|
||||
{
|
||||
YooLogger.Warning("Do nothing when overwrite install application !");
|
||||
}
|
||||
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllCacheFiles)
|
||||
{
|
||||
_fileSystem.DeleteAllBundleFiles();
|
||||
_fileSystem.DeleteAllManifestFiles();
|
||||
YooLogger.Warning("Delete all cache files when overwrite install application !");
|
||||
}
|
||||
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllBundleFiles)
|
||||
{
|
||||
_fileSystem.DeleteAllBundleFiles();
|
||||
YooLogger.Warning("Delete all bundle files when overwrite install application !");
|
||||
}
|
||||
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllManifestFiles)
|
||||
{
|
||||
_fileSystem.DeleteAllManifestFiles();
|
||||
YooLogger.Warning("Delete all manifest files when overwrite install application !");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(_fileSystem.InstallClearMode.ToString());
|
||||
}
|
||||
|
||||
appFootPrint.Coverage(_fileSystem.PackageName);
|
||||
YooLogger.Warning("Delete manifest files when application foot print dirty !");
|
||||
}
|
||||
|
||||
_steps = ESteps.SearchCacheFiles;
|
||||
|
|
|
@ -59,7 +59,8 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
if (ManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||
string fileHash = HashUtility.BytesCRC32(_fileData);
|
||||
if (fileHash == _packageHash)
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,8 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
if (ManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||
string fileHash = HashUtility.BytesCRC32(_fileData);
|
||||
if (fileHash == _packageHash)
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
|
|
|
@ -14,8 +14,7 @@ namespace YooAsset
|
|||
base.OnCreate(packageName, rootDirectory);
|
||||
|
||||
// 注意:重写保存根目录和临时目录
|
||||
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveBundleFilesFolderName);
|
||||
_cacheManifestFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveManifestFilesFolderName);
|
||||
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveFilesFolderName);
|
||||
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.TempFilesFolderName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 保存的资源文件的文件夹名称
|
||||
/// </summary>
|
||||
public const string SaveBundleFilesFolderName = "UnpackBundleFiles";
|
||||
|
||||
/// <summary>
|
||||
/// 保存的清单文件的文件夹名称
|
||||
/// </summary>
|
||||
public const string SaveManifestFilesFolderName = "UnpackManifestFiles";
|
||||
public const string SaveFilesFolderName = "UnpackFiles";
|
||||
|
||||
/// <summary>
|
||||
/// 下载的临时文件的文件夹名称
|
||||
|
|
|
@ -72,7 +72,8 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||
string fileHash = HashUtility.BytesCRC32(_webDataRequestOp.Result);
|
||||
if (fileHash == _packageHash)
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,8 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||
string fileHash = HashUtility.BytesCRC32(_webDataRequestOp.Result);
|
||||
if (fileHash == _packageHash)
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace YooAsset
|
|||
public class FileSystemParametersDefine
|
||||
{
|
||||
public const string FILE_VERIFY_LEVEL = "FILE_VERIFY_LEVEL";
|
||||
public const string INSTALL_CLEAR_MODE = "INSTALL_CLEAR_MODE";
|
||||
public const string REMOTE_SERVICES = "REMOTE_SERVICES";
|
||||
public const string DECRYPTION_SERVICES = "DECRYPTION_SERVICES";
|
||||
public const string APPEND_FILE_EXTENSION = "APPEND_FILE_EXTENSION";
|
||||
|
|
|
@ -8,30 +8,6 @@ namespace YooAsset
|
|||
{
|
||||
internal static class ManifestTools
|
||||
{
|
||||
/// <summary>
|
||||
/// 验证清单文件的二进制数据
|
||||
/// </summary>
|
||||
public static bool VerifyManifestData(byte[] fileData, string hashValue)
|
||||
{
|
||||
if (fileData == null || fileData.Length == 0)
|
||||
return false;
|
||||
if (string.IsNullOrEmpty(hashValue))
|
||||
return false;
|
||||
|
||||
// 注意:兼容俩种验证方式
|
||||
// 注意:计算MD5的哈希值通常为32个字符
|
||||
string fileHash;
|
||||
if (hashValue.Length == 32)
|
||||
fileHash = HashUtility.BytesMD5(fileData);
|
||||
else
|
||||
fileHash = HashUtility.BytesCRC32(fileData);
|
||||
|
||||
if (fileHash == hashValue)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化(JSON文件)
|
||||
/// </summary>
|
||||
|
@ -221,16 +197,9 @@ namespace YooAsset
|
|||
manifest.AssetDic = new Dictionary<string, PackageAsset>(assetCount);
|
||||
|
||||
if (manifest.EnableAddressable)
|
||||
{
|
||||
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (manifest.LocationToLower)
|
||||
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2, StringComparer.OrdinalIgnoreCase);
|
||||
else
|
||||
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2);
|
||||
}
|
||||
|
||||
if (manifest.IncludeAssetGUID)
|
||||
manifest.AssetPathMapping2 = new Dictionary<string, string>(assetCount);
|
||||
|
@ -252,6 +221,8 @@ namespace YooAsset
|
|||
// 填充AssetPathMapping1
|
||||
{
|
||||
string location = packageAsset.AssetPath;
|
||||
if (manifest.LocationToLower)
|
||||
location = location.ToLower();
|
||||
|
||||
// 添加原生路径的映射
|
||||
if (manifest.AssetPathMapping1.ContainsKey(location))
|
||||
|
|
|
@ -138,6 +138,9 @@ namespace YooAsset
|
|||
if (string.IsNullOrEmpty(location))
|
||||
return string.Empty;
|
||||
|
||||
if (LocationToLower)
|
||||
location = location.ToLower();
|
||||
|
||||
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
||||
return assetPath;
|
||||
else
|
||||
|
@ -304,6 +307,9 @@ namespace YooAsset
|
|||
return string.Empty;
|
||||
}
|
||||
|
||||
if (LocationToLower)
|
||||
location = location.ToLower();
|
||||
|
||||
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
||||
{
|
||||
return assetPath;
|
||||
|
|
|
@ -126,7 +126,7 @@ public class PatchWindow : MonoBehaviour
|
|||
{
|
||||
UserEventDefine.UserTryRequestPackageVersion.SendEventMessage();
|
||||
};
|
||||
ShowMessageBox($"Failed to request package version, please check the network status.", callback);
|
||||
ShowMessageBox($"Failed to update static version, please check the network status.", callback);
|
||||
}
|
||||
else if (message is PatchEventDefine.PackageManifestUpdateFailed)
|
||||
{
|
||||
|
|
|
@ -71,7 +71,7 @@ public static class TestPackageBuilder
|
|||
buildParameters.ClearBuildCacheFiles = true;
|
||||
buildParameters.UseAssetDependencyDB = true;
|
||||
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
|
||||
buildParameters.EncryptionServices = new FileStreamTestEncryption();
|
||||
buildParameters.EncryptionServices = new FileStreamEncryption();
|
||||
|
||||
var pipeline = new ScriptableBuildPipeline();
|
||||
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||
|
@ -108,7 +108,7 @@ public static class TestPackageBuilder
|
|||
buildParameters.CompressOption = ECompressOption.LZ4;
|
||||
buildParameters.ClearBuildCacheFiles = true;
|
||||
buildParameters.UseAssetDependencyDB = true;
|
||||
buildParameters.EncryptionServices = new FileStreamTestEncryption();
|
||||
buildParameters.EncryptionServices = new FileStreamEncryption();
|
||||
|
||||
var pipeline = new BuiltinBuildPipeline();
|
||||
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class T2_TestBuldinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||
|
||||
// 初始化资源包
|
||||
var initParams = new OfflinePlayModeParameters();
|
||||
var decryption = new FileStreamTestDecryption();
|
||||
var decryption = new FileStreamDecryption();
|
||||
initParams.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(decryption, packageRoot);
|
||||
var initializeOp = package.InitializeAsync(initParams);
|
||||
yield return initializeOp;
|
||||
|
|
|
@ -34,7 +34,7 @@ public class TestBundleEncryption
|
|||
/// <summary>
|
||||
/// 文件流加密方式
|
||||
/// </summary>
|
||||
public class FileStreamTestEncryption : IEncryptionServices
|
||||
public class FileStreamEncryption : IEncryptionServices
|
||||
{
|
||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ public class FileStreamTestEncryption : IEncryptionServices
|
|||
/// <summary>
|
||||
/// 文件偏移加密方式
|
||||
/// </summary>
|
||||
public class FileOffsetTestEncryption : IEncryptionServices
|
||||
public class FileOffsetEncryption : IEncryptionServices
|
||||
{
|
||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ public class BundleStream : FileStream
|
|||
/// <summary>
|
||||
/// 资源文件流解密类
|
||||
/// </summary>
|
||||
public class FileStreamTestDecryption : IDecryptionServices
|
||||
public class FileStreamDecryption : IDecryptionServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 同步方式获取解密的资源包对象
|
||||
|
@ -172,7 +172,7 @@ public class FileStreamTestDecryption : IDecryptionServices
|
|||
/// <summary>
|
||||
/// 资源文件偏移解密类
|
||||
/// </summary>
|
||||
public class FileOffsetTestDecryption : IDecryptionServices
|
||||
public class FileOffsetDecryption : IDecryptionServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 同步方式获取解密的资源包对象
|
||||
|
@ -224,7 +224,7 @@ public class FileOffsetTestDecryption : IDecryptionServices
|
|||
/// WebGL平台解密类
|
||||
/// 注意:WebGL平台支持内存解密
|
||||
/// </summary>
|
||||
public class WebFileStreamTestDecryption : IWebDecryptionServices
|
||||
public class WebFileStreamDecryption : IWebDecryptionServices
|
||||
{
|
||||
public WebDecryptResult LoadAssetBundle(WebDecryptFileInfo fileInfo)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue