diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs index e23b6a5..1ec57f9 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs @@ -58,11 +58,16 @@ namespace YooAsset.Editor /// public readonly BuildPatchInfo PatchInfo = new BuildPatchInfo(); + /// + /// Bundle文件的加载方法 + /// + public EBundleLoadMethod LoadMethod { set; get; } + /// /// 加密生成文件的路径 /// 注意:如果未加密该路径为空 /// - public string EncryptedFilePath { set; get; } = string.Empty; + public string EncryptedFilePath { set; get; } /// /// 是否为原生文件 @@ -177,9 +182,13 @@ namespace YooAsset.Editor /// internal PatchBundle CreatePatchBundle() { + string fileHash = PatchInfo.PatchFileHash; + string fileCRC = PatchInfo.PatchFileCRC; + long fileSize = PatchInfo.PatchFileSize; + bool isRawFile = IsRawFile; + byte loadMethod = (byte)LoadMethod; string[] tags = GetBundleTags(); - PatchBundle patchBundle = new PatchBundle(BundleName, PatchInfo.PatchFileHash, PatchInfo.PatchFileCRC, PatchInfo.PatchFileSize, tags); - patchBundle.SetFlagsValue(IsRawFile, IsEncryptedFile); + PatchBundle patchBundle = new PatchBundle(BundleName, fileHash, fileCRC, fileSize, isRawFile, loadMethod, tags); return patchBundle; } } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs index 632f53b..c34828a 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs @@ -8,21 +8,6 @@ namespace YooAsset.Editor [Serializable] public class ReportBundleInfo { - public class FlagsData - { - public bool IsEncrypted { private set; get; } - public bool IsBuildin { private set; get; } - public bool IsRawFile { private set; get; } - public FlagsData(bool isEncrypted, bool isBuildin, bool isRawFile) - { - IsEncrypted = isEncrypted; - IsBuildin = isBuildin; - IsRawFile = isRawFile; - } - } - - private FlagsData _flagData; - /// /// 资源包名称 /// @@ -48,33 +33,21 @@ namespace YooAsset.Editor /// public long FileSize; + /// + /// 是否为原生文件 + /// + public bool IsRawFile; + + /// + /// 加载方法 + /// + public EBundleLoadMethod LoadMethod; + /// /// Tags /// public string[] Tags; - /// - /// Flags - /// - public int Flags; - - - /// - /// 获取标志位的解析数据 - /// - public FlagsData GetFlagData() - { - if (_flagData == null) - { - BitMask32 value = Flags; - bool isEncrypted = value.Test(0); - bool isBuildin = value.Test(1); - bool isRawFile = value.Test(2); - _flagData = new FlagsData(isEncrypted, isBuildin, isRawFile); - } - return _flagData; - } - /// /// 获取资源分类标签的字符串 /// @@ -85,16 +58,5 @@ namespace YooAsset.Editor else return string.Empty; } - - /// - /// 是否为原生文件 - /// - public bool IsRawFile() - { - if (System.IO.Path.GetExtension(BundleName) == $".{YooAssetSettingsData.Setting.RawFileVariant}") - return true; - else - return false; - } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs index 6f620ca..4969c22 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs @@ -98,7 +98,8 @@ namespace YooAsset.Editor reportBundleInfo.FileCRC = patchBundle.FileCRC; reportBundleInfo.FileSize = patchBundle.FileSize; reportBundleInfo.Tags = patchBundle.Tags; - reportBundleInfo.Flags = patchBundle.Flags; + reportBundleInfo.IsRawFile = patchBundle.IsRawFile; + reportBundleInfo.LoadMethod = (EBundleLoadMethod)patchBundle.LoadMethod; buildReport.BundleInfos.Add(reportBundleInfo); } @@ -178,7 +179,7 @@ namespace YooAsset.Editor int fileCount = 0; foreach (var patchBundle in patchManifest.BundleList) { - if (patchBundle.IsEncrypted) + if (patchBundle.LoadMethod != (byte)EBundleLoadMethod.Normal) fileCount++; } return fileCount; @@ -188,7 +189,7 @@ namespace YooAsset.Editor long fileBytes = 0; foreach (var patchBundle in patchManifest.BundleList) { - if (patchBundle.IsEncrypted) + if (patchBundle.LoadMethod != (byte)EBundleLoadMethod.Normal) fileBytes += patchBundle.FileSize; } return fileBytes; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs index 117e1a2..96ffe6a 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs @@ -36,21 +36,27 @@ namespace YooAsset.Editor string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory(); foreach (var bundleInfo in buildMapContext.BundleInfos) { - if (encryptionServices.Check(bundleInfo.BundleName)) + bundleInfo.LoadMethod = EBundleLoadMethod.Normal; + + EncryptFileInfo fileInfo = new EncryptFileInfo(); + fileInfo.BundleName = bundleInfo.BundleName; + fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; + + var encryptResult = encryptionServices.Encrypt(fileInfo); + if (encryptResult.LoadMethod != EBundleLoadMethod.Normal) { + // 注意:原生文件不支持加密 if (bundleInfo.IsRawFile) { UnityEngine.Debug.LogWarning($"Encryption not support raw file : {bundleInfo.BundleName}"); continue; } - string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; - string savePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}.encrypt"; - byte[] fileData = File.ReadAllBytes(filePath); - byte[] encryptData = encryptionServices.Encrypt(fileData); - FileUtility.CreateFile(savePath, encryptData); - bundleInfo.EncryptedFilePath = savePath; - BuildRunner.Log($"Bundle文件加密完成:{savePath}"); + string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}.encrypt"; + FileUtility.CreateFile(filePath, encryptResult.EncryptedData); + bundleInfo.EncryptedFilePath = filePath; + bundleInfo.LoadMethod = encryptResult.LoadMethod; + BuildRunner.Log($"Bundle文件加密完成:{filePath}"); } // 进度条 diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/IEncryptionServices.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/IEncryptionServices.cs deleted file mode 100644 index 3adee29..0000000 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/IEncryptionServices.cs +++ /dev/null @@ -1,18 +0,0 @@ - -namespace YooAsset.Editor -{ - public interface IEncryptionServices - { - /// - /// 检测是否需要加密 - /// - bool Check(string bundleName); - - /// - /// 加密方法 - /// - /// 要加密的文件数据 - /// 返回加密后的字节数据 - byte[] Encrypt(byte[] fileData); - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/IEncryptionServices.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/IEncryptionServices.cs.meta deleted file mode 100644 index 3991708..0000000 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/IEncryptionServices.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 04491137351983348959c00ec4ee226a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs index 0fa8ff4..35d800e 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs @@ -25,7 +25,7 @@ namespace YooAsset.Editor private ToolbarButton _topBar1; private ToolbarButton _topBar2; private ToolbarButton _topBar3; - private ToolbarButton _topBar4; + private ToolbarButton _topBar5; private ToolbarButton _bottomBar1; private ListView _bundleListView; private ListView _includeListView; @@ -53,11 +53,11 @@ namespace YooAsset.Editor _topBar1 = _root.Q("TopBar1"); _topBar2 = _root.Q("TopBar2"); _topBar3 = _root.Q("TopBar3"); - _topBar4 = _root.Q("TopBar4"); + _topBar5 = _root.Q("TopBar5"); _topBar1.clicked += TopBar1_clicked; _topBar2.clicked += TopBar2_clicked; _topBar3.clicked += TopBar3_clicked; - _topBar4.clicked += TopBar4_clicked; + _topBar5.clicked += TopBar4_clicked; // 底部按钮栏 _bottomBar1 = _root.Q("BottomBar1"); @@ -144,7 +144,7 @@ namespace YooAsset.Editor _topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count})"; _topBar2.text = "Size"; _topBar3.text = "Hash"; - _topBar4.text = "Tags"; + _topBar5.text = "Tags"; if (_sortMode == ESortMode.BundleName) { @@ -163,9 +163,9 @@ namespace YooAsset.Editor else if (_sortMode == ESortMode.BundleTags) { if (_descendingSort) - _topBar4.text = "Tags ↓"; + _topBar5.text = "Tags ↓"; else - _topBar4.text = "Tags ↑"; + _topBar5.text = "Tags ↑"; } else { @@ -231,6 +231,16 @@ namespace YooAsset.Editor label.name = "Label5"; label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.marginLeft = 3f; + //label.style.flexGrow = 1f; + label.style.width = 150; + element.Add(label); + } + + { + var label = new Label(); + label.name = "Label6"; + label.style.unityTextAlign = TextAnchor.MiddleLeft; + label.style.marginLeft = 3f; label.style.flexGrow = 1f; label.style.width = 80; element.Add(label); @@ -255,9 +265,13 @@ namespace YooAsset.Editor var label3 = element.Q