mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-25 18:20:15 +00:00
Compare commits
21 Commits
3.0.0-beta
...
yoo3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c05f3514e | ||
|
|
b31bb1bcfb | ||
|
|
92e34fb8b5 | ||
|
|
687dc1d9e9 | ||
|
|
7842235af6 | ||
|
|
0142828b91 | ||
|
|
a36a7cc6d2 | ||
|
|
485ed5198e | ||
|
|
2170156216 | ||
|
|
99b975554a | ||
|
|
2f8355c3f4 | ||
|
|
f05f794461 | ||
|
|
a5ec8e8eb9 | ||
|
|
c0c3bb406d | ||
|
|
656b8f18e2 | ||
|
|
429a7395ca | ||
|
|
f8f2dd8faf | ||
|
|
45ecd8baff | ||
|
|
322c4a9847 | ||
|
|
6b23927f71 | ||
|
|
dfa9ff6954 |
@@ -2,6 +2,57 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [3.0.1-beta] - 2026-05-19
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增归档文件构建管线 `ArchiveFileBuildPipeline`
|
||||||
|
|
||||||
|
支持将同一资源包内的多个原始文件合并为 `ArchiveBundle`,并提供构建参数、构建任务、编辑器构建界面和运行时加载支持。
|
||||||
|
|
||||||
|
- 新增 `EnsureBundleFileOperation` 操作
|
||||||
|
|
||||||
|
用于确保资源包文件已就绪,并通过 `EnsureBundleFileOperation.Detail` 获取资源包名称、本地文件路径、资源包类型和加密状态。
|
||||||
|
|
||||||
|
**代码示例**
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var package = YooAssets.GetPackage("DefaultPackage");
|
||||||
|
|
||||||
|
// 确保资源所在的资源包文件已经就绪。
|
||||||
|
// 如果资源包未缓存,会自动触发下载或解压流程。
|
||||||
|
var operation = package.EnsureBundleFileAsync(new EnsureBundleFileOptions("asset_location"));
|
||||||
|
yield return operation;
|
||||||
|
|
||||||
|
if (operation.Status == EOperationStatus.Succeeded)
|
||||||
|
{
|
||||||
|
var detail = operation.Detail;
|
||||||
|
string bundleName = detail.BundleName;
|
||||||
|
string bundleFilePath = detail.BundleFilePath;
|
||||||
|
int bundleType = detail.BundleType;
|
||||||
|
bool isEncrypted = detail.IsEncrypted;
|
||||||
|
|
||||||
|
UnityEngine.Debug.Log($"BundleName: {bundleName}");
|
||||||
|
UnityEngine.Debug.Log($"BundleFilePath: {bundleFilePath}");
|
||||||
|
UnityEngine.Debug.Log($"BundleType: {bundleType}");
|
||||||
|
UnityEngine.Debug.Log($"IsEncrypted: {isEncrypted}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogError(operation.Error);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 新增编辑器模拟模式下的 Bundle Cache 标记文件机制
|
||||||
|
|
||||||
|
通过记录缓存状态,提升虚拟下载模式下缓存扫描、恢复和清理的可靠性。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `LoadRawFile` API 重命名为 `LoadBundleFile`
|
||||||
|
|
||||||
|
对应句柄由 `RawFileHandle` 重命名为 `BundleFileHandle`,语义从“原生文件”调整为“资源包文件”。
|
||||||
|
|
||||||
## [3.0.0-beta] - 2026-05-09
|
## [3.0.0-beta] - 2026-05-09
|
||||||
|
|
||||||
beta released.
|
beta released.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 2e49e0ae672b9944783571b2ad737df9
|
guid: da26c791ca572fe4a818405173661568
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建辅助工具类
|
||||||
|
/// </summary>
|
||||||
|
internal static class ArchiveFileBuildHelper
|
||||||
|
{
|
||||||
|
private const int StreamCopyBufferSize = 81920;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 收集构建资源的归档条目列表,并按 FilePath 字典序排序
|
||||||
|
/// </summary>
|
||||||
|
public static List<ArchiveFileEntry> CollectEntries(IReadOnlyList<BuildAssetInfo> allAssets)
|
||||||
|
{
|
||||||
|
var entries = new List<ArchiveFileEntry>(allAssets.Count);
|
||||||
|
foreach (var asset in allAssets)
|
||||||
|
{
|
||||||
|
string assetPath = asset.AssetInfo.AssetPath;
|
||||||
|
long dataLength = new FileInfo(assetPath).Length;
|
||||||
|
uint crc = HashUtility.ComputeFileCrc32AsUInt(assetPath);
|
||||||
|
entries.Add(new ArchiveFileEntry(assetPath, dataLength, crc));
|
||||||
|
}
|
||||||
|
|
||||||
|
entries.Sort((a, b) => string.Compare(a.AssetPath, b.AssetPath, StringComparison.Ordinal));
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 计算每个条目的绝对偏移,并写入归档文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="outputPath">输出文件路径</param>
|
||||||
|
/// <param name="entries">归档条目列表</param>
|
||||||
|
/// <param name="fileAlignment">文件数据对齐字节数(0 表示不对齐)</param>
|
||||||
|
public static void BuildArchiveFile(string outputPath, List<ArchiveFileEntry> entries, int fileAlignment)
|
||||||
|
{
|
||||||
|
int fileCount = entries.Count;
|
||||||
|
if (fileCount > ArchiveBundleConsts.MaxChildFileCount)
|
||||||
|
throw new InvalidOperationException($"Archive child file count {fileCount} exceeds maximum ({ArchiveBundleConsts.MaxChildFileCount}).");
|
||||||
|
|
||||||
|
// 1. 计算 header 总大小
|
||||||
|
int headerSize = 4 + 4 + 4; // Magic + Version + FileCount
|
||||||
|
foreach (var entry in entries)
|
||||||
|
{
|
||||||
|
byte[] pathBytes = entry.GetPathBytes();
|
||||||
|
// FilePathLen(4) + FilePath(变长) + DataOffset(8) + DataLength(8) + FileCRC(4)
|
||||||
|
headerSize += 4 + pathBytes.Length + 8 + 8 + 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 计算每个文件的绝对偏移
|
||||||
|
long currentOffset = headerSize;
|
||||||
|
foreach (var entry in entries)
|
||||||
|
{
|
||||||
|
if (fileAlignment > 0)
|
||||||
|
currentOffset = AlignOffset(currentOffset, fileAlignment);
|
||||||
|
entry.DataOffset = currentOffset;
|
||||||
|
currentOffset += entry.DataLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 写入归档文件
|
||||||
|
EditorFileUtility.CreateFileDirectory(outputPath);
|
||||||
|
using (var fs = new FileStream(outputPath, FileMode.Create, FileAccess.Write))
|
||||||
|
using (var writer = new BinaryWriter(fs))
|
||||||
|
{
|
||||||
|
// Header
|
||||||
|
writer.Write(ArchiveBundleConsts.FileMagic);
|
||||||
|
writer.Write(ArchiveBundleConsts.FileVersion);
|
||||||
|
writer.Write(fileCount);
|
||||||
|
|
||||||
|
foreach (var entry in entries)
|
||||||
|
{
|
||||||
|
byte[] pathBytes = entry.GetPathBytes();
|
||||||
|
writer.Write(pathBytes.Length);
|
||||||
|
writer.Write(pathBytes);
|
||||||
|
writer.Write(entry.DataOffset);
|
||||||
|
writer.Write(entry.DataLength);
|
||||||
|
writer.Write(entry.FileCRC);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data: 按排序后的顺序写入,使用流式拷贝避免大文件 OOM
|
||||||
|
byte[] buffer = new byte[StreamCopyBufferSize];
|
||||||
|
foreach (var entry in entries)
|
||||||
|
{
|
||||||
|
// 填充对齐字节
|
||||||
|
long paddingSize = entry.DataOffset - fs.Position;
|
||||||
|
if (paddingSize > 0)
|
||||||
|
writer.Write(new byte[paddingSize]);
|
||||||
|
|
||||||
|
using (var sourceStream = new FileStream(entry.AssetPath, FileMode.Open, FileAccess.Read))
|
||||||
|
{
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = sourceStream.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
|
{
|
||||||
|
writer.Write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将偏移值向上对齐到指定字节边界
|
||||||
|
/// </summary>
|
||||||
|
private static long AlignOffset(long offset, int alignment)
|
||||||
|
{
|
||||||
|
return (offset + alignment - 1) / alignment * alignment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: f11e7e5e45702bb459771f57e1b84fdc
|
guid: 3f8daa3aacb5da8458fc073431da1891
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线的构建参数
|
||||||
|
/// </summary>
|
||||||
|
public class ArchiveFileBuildParameters : BuildParameters
|
||||||
|
{
|
||||||
|
private const int MaxFileAlignment = 4096;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件哈希值计算包含路径信息
|
||||||
|
/// </summary>
|
||||||
|
public bool IncludePathInHash { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件内数据对齐字节数(0 表示不对齐)
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 对齐后每个子文件的数据偏移会向上取整到该值的整数倍,文件间以零字节填充。
|
||||||
|
/// 推荐值:4(通用对齐)、512(磁盘扇区对齐)、4096(内存页对齐)。
|
||||||
|
/// </remarks>
|
||||||
|
public int FileAlignment { get; set; } = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void CheckBuildParametersCore()
|
||||||
|
{
|
||||||
|
// ArchiveBundle 不支持资源包加密
|
||||||
|
if (BundleEncryptor != null)
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleEncryptionNotSupported,
|
||||||
|
$"ArchiveFileBuildPipeline does not support bundle encryption. Please remove the BundleEncryptor configuration.");
|
||||||
|
throw new NotSupportedException(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验文件对齐参数范围
|
||||||
|
if (FileAlignment < 0 || FileAlignment > MaxFileAlignment)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(FileAlignment),
|
||||||
|
$"FileAlignment must be between 0 and {MaxFileAlignment}. Current value: {FileAlignment}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 2c5756c583ed1474c9abb56419b488d6
|
guid: 83bdf0f6502d23f49ae900d98f459c7b
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线,将同一 BundleName 下的多个原始文件合并写入一个归档文件
|
||||||
|
/// </summary>
|
||||||
|
public class ArchiveFileBuildPipeline : IBuildPipeline
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 执行构建流程
|
||||||
|
/// </summary>
|
||||||
|
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||||
|
{
|
||||||
|
if (buildParameters is ArchiveFileBuildParameters)
|
||||||
|
{
|
||||||
|
BundleBuilder builder = new BundleBuilder();
|
||||||
|
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"Invalid build parameter type: '{buildParameters.GetType().Name}'.", nameof(buildParameters));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取默认的构建流程
|
||||||
|
/// </summary>
|
||||||
|
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||||
|
{
|
||||||
|
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||||
|
{
|
||||||
|
new TaskPrepare_AFBP(),
|
||||||
|
new TaskGetBuildMap_AFBP(),
|
||||||
|
new TaskBuilding_AFBP(),
|
||||||
|
new TaskEncryption_AFBP(),
|
||||||
|
new TaskUpdateBundleInfo_AFBP(),
|
||||||
|
new TaskCreateManifest_AFBP(),
|
||||||
|
new TaskCreateReport_AFBP(),
|
||||||
|
new TaskCreatePackage_AFBP(),
|
||||||
|
new TaskCopyBundledFiles_AFBP(),
|
||||||
|
new TaskCreateCatalog_AFBP()
|
||||||
|
};
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 19ef6fc50bd422c4db6fa53cbf0fe226
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件条目信息(构建期临时数据结构)
|
||||||
|
/// </summary>
|
||||||
|
internal class ArchiveFileEntry
|
||||||
|
{
|
||||||
|
private byte[] _pathBytes;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件路径
|
||||||
|
/// </summary>
|
||||||
|
public readonly string AssetPath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件数据长度
|
||||||
|
/// </summary>
|
||||||
|
public readonly long DataLength;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件 CRC32
|
||||||
|
/// </summary>
|
||||||
|
public readonly uint FileCRC;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据在归档文件中的绝对偏移
|
||||||
|
/// </summary>
|
||||||
|
public long DataOffset;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构造归档文件条目
|
||||||
|
/// </summary>
|
||||||
|
public ArchiveFileEntry(string assetPath, long dataLength, uint fileCRC)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(assetPath))
|
||||||
|
throw new ArgumentException("Asset path is null or empty.", nameof(assetPath));
|
||||||
|
if (dataLength < 0)
|
||||||
|
throw new ArgumentException($"Invalid data length {dataLength} for '{assetPath}'.", nameof(dataLength));
|
||||||
|
if (dataLength > ArchiveBundleConsts.MaxChildFileSize)
|
||||||
|
throw new ArgumentException($"Child file exceeds maximum size ({ArchiveBundleConsts.MaxChildFileSize} bytes): '{assetPath}' ({dataLength} bytes).", nameof(dataLength));
|
||||||
|
|
||||||
|
AssetPath = assetPath;
|
||||||
|
DataLength = dataLength;
|
||||||
|
FileCRC = fileCRC;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取文件路径的 UTF8 字节缓存
|
||||||
|
/// </summary>
|
||||||
|
public byte[] GetPathBytes()
|
||||||
|
{
|
||||||
|
if (_pathBytes == null)
|
||||||
|
_pathBytes = Encoding.UTF8.GetBytes(AssetPath);
|
||||||
|
return _pathBytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a03062dc3dd175c438fcb92d3e06a33b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b9dccc7a4589001469444e571235890a
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线的核心构建任务
|
||||||
|
/// </summary>
|
||||||
|
public class TaskBuilding_AFBP : IBuildTask
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildParameters = buildParametersContext.Parameters as ArchiveFileBuildParameters;
|
||||||
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
|
|
||||||
|
int progressValue = 0;
|
||||||
|
int fileTotalCount = buildMapContext.Collection.Count;
|
||||||
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
|
{
|
||||||
|
string archiveFilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
|
var entries = ArchiveFileBuildHelper.CollectEntries(bundleInfo.AllPackAssets);
|
||||||
|
ArchiveFileBuildHelper.BuildArchiveFile(archiveFilePath, entries, buildParameters.FileAlignment);
|
||||||
|
EditorDialogUtility.DisplayProgressBar("Build archive files", ++progressValue, fileTotalCount);
|
||||||
|
}
|
||||||
|
EditorDialogUtility.ClearProgressBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 289e760820002e34b9054a81098d5fa4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线的首包资源拷贝任务
|
||||||
|
/// </summary>
|
||||||
|
public class TaskCopyBundledFiles_AFBP : TaskCopyBundledFiles, IBuildTask
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
if (buildParameters.BundledCopyOption != EBundledCopyOption.None)
|
||||||
|
{
|
||||||
|
CopyBundledFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e4fb32a77b3e799448cf4eae2a97a49e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线的资源目录创建任务
|
||||||
|
/// </summary>
|
||||||
|
public class TaskCreateCatalog_AFBP : TaskCreateCatalog, IBuildTask
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
if (buildParametersContext.Parameters.BundledCopyOption != EBundledCopyOption.None)
|
||||||
|
{
|
||||||
|
CreateCatalogFile(buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 813f7821d87b6f8498ddc4d675512413
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线的清单创建任务
|
||||||
|
/// </summary>
|
||||||
|
public class TaskCreateManifest_AFBP : TaskCreateManifest, IBuildTask
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
CreateManifestFile(false, true, false, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
|
{
|
||||||
|
return Array.Empty<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 21e10b308293d2e45972a9b4ba143a74
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线的补丁包创建任务
|
||||||
|
/// </summary>
|
||||||
|
public class TaskCreatePackage_AFBP : TaskCreatePackage, IBuildTask
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
CreatePackagePatch(buildParametersContext, buildMapContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreatePackagePatch(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
|
{
|
||||||
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
|
BuildLogger.Log($"Start making patch package: '{packageOutputDirectory}'.");
|
||||||
|
CopyPackageBundles(buildMapContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 721f0030551d41c40a2c6d3206c3897a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线的构建报告创建任务
|
||||||
|
/// </summary>
|
||||||
|
public class TaskCreateReport_AFBP : TaskCreateReport, IBuildTask
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3e12187230b544940aeae7cb3c556299
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线的加密任务
|
||||||
|
/// </summary>
|
||||||
|
public class TaskEncryption_AFBP : TaskEncryption, IBuildTask
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 16ff5758e3a98b64193c61ca68e94ddd
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线的构建映射生成任务
|
||||||
|
/// </summary>
|
||||||
|
public class TaskGetBuildMap_AFBP : TaskGetBuildMap, IBuildTask
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = CreateBuildMap(true, buildParametersContext.Parameters);
|
||||||
|
context.SetContextObject(buildMapContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 409de066b34f4b64fa9eaee790045492
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线的准备任务
|
||||||
|
/// </summary>
|
||||||
|
public class TaskPrepare_AFBP : TaskPrepare, IBuildTask
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
|
||||||
|
// 检测构建参数
|
||||||
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
|
||||||
|
// 检测未保存场景
|
||||||
|
CheckDirtyScenes();
|
||||||
|
|
||||||
|
// 删除历史缓存
|
||||||
|
if (buildParameters.ClearBuildCacheFiles)
|
||||||
|
{
|
||||||
|
DeletePackageRootDirectory(buildParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 准备输出目录
|
||||||
|
PrepareOutputDirectory(buildParameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f463d370e0512bb4c8d79e22fe149500
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线的资源包信息更新任务
|
||||||
|
/// </summary>
|
||||||
|
public class TaskUpdateBundleInfo_AFBP : TaskUpdateBundleInfo, IBuildTask
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
UpdateBundleInfo(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
return ComputeFileHash(bundleInfo, context);
|
||||||
|
}
|
||||||
|
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
return ComputeFileHash(bundleInfo, context);
|
||||||
|
}
|
||||||
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
|
return HashUtility.ComputeFileCrc32AsUInt(filePath);
|
||||||
|
}
|
||||||
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
|
return FileUtility.GetFileSize(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ComputeFileHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var parameters = buildParametersContext.Parameters as ArchiveFileBuildParameters;
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
|
if (parameters.IncludePathInHash)
|
||||||
|
return GetFileMD5IncludePath(filePath);
|
||||||
|
else
|
||||||
|
return HashUtility.ComputeFileMD5(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6263649b351967840836e9ca443c5574
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
|
namespace YooAsset.Editor
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器模拟构建管线的构建映射生成任务
|
/// 编辑器模拟构建管线的构建映射生成任务
|
||||||
@@ -13,10 +12,17 @@ namespace YooAsset.Editor
|
|||||||
var buildMapContext = CreateBuildMap(true, buildParametersContext.Parameters);
|
var buildMapContext = CreateBuildMap(true, buildParametersContext.Parameters);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
|
|
||||||
if (buildParametersContext.Parameters.BuildBundleType == (int)EBundleType.RawBundle)
|
// 注意:检查每个原生文件资源包只能包含一个原生文件
|
||||||
|
if (buildParametersContext.Parameters.BuildBundleType == (int)EBundleType.VirtualRawBundle)
|
||||||
{
|
{
|
||||||
CheckRawBundleMapContent(buildMapContext);
|
CheckRawBundleMapContent(buildMapContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查归档资源包内每个子文件大小不超过上限
|
||||||
|
if (buildParametersContext.Parameters.BuildBundleType == (int)EBundleType.VirtualArchiveBundle)
|
||||||
|
{
|
||||||
|
CheckArchiveBundleMapContent(buildMapContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
@@ -6,5 +7,18 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EditorSimulateBuildParameters : BuildParameters
|
public class EditorSimulateBuildParameters : BuildParameters
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void CheckBuildParametersCore()
|
||||||
|
{
|
||||||
|
// EditorSimulateBuildPipeline 只允许 VirtualBundle 类型
|
||||||
|
if (BuildBundleType != (int)EBundleType.VirtualAssetBundle &&
|
||||||
|
BuildBundleType != (int)EBundleType.VirtualRawBundle &&
|
||||||
|
BuildBundleType != (int)EBundleType.VirtualArchiveBundle)
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildBundleTypeNotSupported,
|
||||||
|
$"{nameof(EditorSimulateBuildPipeline)} only supports VirtualBundle types. Received: {(EBundleType)BuildBundleType}.");
|
||||||
|
throw new InvalidOperationException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ namespace YooAsset.Editor
|
|||||||
/// <remarks>开启此项可以节省运行时清单占用的内存</remarks>
|
/// <remarks>开启此项可以节省运行时清单占用的内存</remarks>
|
||||||
public bool ReplaceAssetPathWithAddress = false;
|
public bool ReplaceAssetPathWithAddress = false;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取旧版构建管线的构建选项
|
/// 获取旧版构建管线的构建选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
BuildLogger.Log($"Start making patch package: '{packageOutputDirectory}'.");
|
BuildLogger.Log($"Start making patch package: '{packageOutputDirectory}'.");
|
||||||
|
|
||||||
// 拷贝所有补丁文件
|
|
||||||
CopyPackageBundles(buildMapContext);
|
CopyPackageBundles(buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
@@ -16,6 +15,9 @@ namespace YooAsset.Editor
|
|||||||
// 检测构建参数
|
// 检测构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
|
||||||
|
// 检测未保存场景
|
||||||
|
CheckDirtyScenes();
|
||||||
|
|
||||||
// 删除历史缓存
|
// 删除历史缓存
|
||||||
if (buildParameters.ClearBuildCacheFiles)
|
if (buildParameters.ClearBuildCacheFiles)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEditor;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
@@ -19,18 +16,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
return ComputeFileHash(bundleInfo, context);
|
||||||
var rawFileBuildParameters = buildParametersContext.Parameters as RawFileBuildParameters;
|
|
||||||
if (rawFileBuildParameters.IncludePathInHash)
|
|
||||||
{
|
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
|
||||||
return GetFileMD5IncludePath(filePath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
|
||||||
return HashUtility.ComputeFileMD5(filePath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
@@ -38,18 +24,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
return ComputeFileHash(bundleInfo, context);
|
||||||
var rawFileBuildParameters = buildParametersContext.Parameters as RawFileBuildParameters;
|
|
||||||
if (rawFileBuildParameters.IncludePathInHash)
|
|
||||||
{
|
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
|
||||||
return GetFileMD5IncludePath(filePath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
|
||||||
return HashUtility.ComputeFileMD5(filePath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
@@ -62,12 +37,15 @@ namespace YooAsset.Editor
|
|||||||
return FileUtility.GetFileSize(filePath);
|
return FileUtility.GetFileSize(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetFileMD5IncludePath(string filePath)
|
private string ComputeFileHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
string pathHash = HashUtility.ComputeMD5(filePath.ToLowerInvariant());
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
string contentHash = HashUtility.ComputeFileMD5(filePath);
|
var parameters = buildParametersContext.Parameters as RawFileBuildParameters;
|
||||||
string combined = pathHash + contentHash;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.ComputeMD5(combined);
|
if (parameters.IncludePathInHash)
|
||||||
|
return GetFileMD5IncludePath(filePath);
|
||||||
|
else
|
||||||
|
return HashUtility.ComputeFileMD5(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEditor;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
@@ -11,7 +10,7 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
|
||||||
// 检测构建参数
|
// 检测构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
@@ -29,13 +28,6 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 准备输出目录
|
// 准备输出目录
|
||||||
PrepareOutputDirectory(buildParameters);
|
PrepareOutputDirectory(buildParameters);
|
||||||
|
|
||||||
// 检测内置着色器资源包名称
|
|
||||||
if (string.IsNullOrEmpty(buildParameters.BuiltinShadersBundleName))
|
|
||||||
{
|
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.BuiltinShadersBundleNameIsNull, "Builtin shaders bundle name is null. It will cause resource redundancy.");
|
|
||||||
BuildLogger.Warning(warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,17 @@ namespace YooAsset.Editor
|
|||||||
public string MonoScriptsBundleName;
|
public string MonoScriptsBundleName;
|
||||||
|
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void CheckBuildParametersCore()
|
||||||
|
{
|
||||||
|
// 检测内置着色器资源包名称
|
||||||
|
if (string.IsNullOrEmpty(BuiltinShadersBundleName))
|
||||||
|
{
|
||||||
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.BuiltinShadersBundleNameIsNull, "Builtin shaders bundle name is null. It will cause resource redundancy.");
|
||||||
|
BuildLogger.Warning(warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取可编程构建管线的构建参数
|
/// 获取可编程构建管线的构建参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -58,6 +58,16 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
BuildBundleTypeIsUnknown = 117,
|
BuildBundleTypeIsUnknown = 117,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建管线不支持指定的资源包类型
|
||||||
|
/// </summary>
|
||||||
|
BuildBundleTypeNotSupported = 118,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建管线不支持资源包加密
|
||||||
|
/// </summary>
|
||||||
|
BundleEncryptionNotSupported = 119,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 建议使用 SBP 构建管线
|
/// 建议使用 SBP 构建管线
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -270,5 +270,27 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测归档资源包内每个子文件是否超过最大允许大小
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="buildMapContext">构建映射上下文</param>
|
||||||
|
protected void CheckArchiveBundleMapContent(BuildMapContext buildMapContext)
|
||||||
|
{
|
||||||
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
|
{
|
||||||
|
foreach (var asset in bundleInfo.AllPackAssets)
|
||||||
|
{
|
||||||
|
string assetPath = asset.AssetInfo.AssetPath;
|
||||||
|
long fileSize = EditorFileUtility.GetFileSize(assetPath);
|
||||||
|
if (fileSize > ArchiveBundleConsts.MaxChildFileSize)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
$"Archive child file exceeds maximum size ({ArchiveBundleConsts.MaxChildFileSize} bytes): " +
|
||||||
|
$"'{assetPath}' ({fileSize} bytes) in bundle '{bundleInfo.BundleName}'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,5 +106,16 @@ namespace YooAsset.Editor
|
|||||||
/// <param name="context">构建上下文</param>
|
/// <param name="context">构建上下文</param>
|
||||||
/// <returns>文件大小</returns>
|
/// <returns>文件大小</returns>
|
||||||
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context);
|
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 计算包含路径信息的文件 MD5
|
||||||
|
/// </summary>
|
||||||
|
protected string GetFileMD5IncludePath(string filePath)
|
||||||
|
{
|
||||||
|
string pathHash = HashUtility.ComputeMD5(filePath.ToLowerInvariant());
|
||||||
|
string contentHash = HashUtility.ComputeFileMD5(filePath);
|
||||||
|
string combined = pathHash + contentHash;
|
||||||
|
return HashUtility.ComputeMD5(combined);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,9 +16,7 @@ namespace YooAsset.Editor
|
|||||||
/// <returns>包裹构建结果</returns>
|
/// <returns>包裹构建结果</returns>
|
||||||
public static PackageBuildResult SimulateBuild(PackageBuildParameters buildParam)
|
public static PackageBuildResult SimulateBuild(PackageBuildParameters buildParam)
|
||||||
{
|
{
|
||||||
string packageName = buildParam.PackageName;
|
|
||||||
string buildPipelineName = buildParam.BuildPipelineName;
|
string buildPipelineName = buildParam.BuildPipelineName;
|
||||||
|
|
||||||
if (buildPipelineName == EBuildPipeline.EditorSimulateBuildPipeline.ToString())
|
if (buildPipelineName == EBuildPipeline.EditorSimulateBuildPipeline.ToString())
|
||||||
{
|
{
|
||||||
var buildParameters = new EditorSimulateBuildParameters();
|
var buildParameters = new EditorSimulateBuildParameters();
|
||||||
@@ -27,7 +25,7 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.BuildPipeline = EBuildPipeline.EditorSimulateBuildPipeline.ToString();
|
buildParameters.BuildPipeline = EBuildPipeline.EditorSimulateBuildPipeline.ToString();
|
||||||
buildParameters.BuildBundleType = buildParam.BuildBundleType;
|
buildParameters.BuildBundleType = buildParam.BuildBundleType;
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
buildParameters.PackageName = packageName;
|
buildParameters.PackageName = buildParam.PackageName;
|
||||||
buildParameters.PackageVersion = "Simulate";
|
buildParameters.PackageVersion = "Simulate";
|
||||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||||
buildParameters.BundledCopyOption = EBundledCopyOption.None;
|
buildParameters.BundledCopyOption = EBundledCopyOption.None;
|
||||||
|
|||||||
@@ -30,5 +30,10 @@ namespace YooAsset.Editor
|
|||||||
/// 团结引擎 InstantAsset 构建管线 (IABP)
|
/// 团结引擎 InstantAsset 构建管线 (IABP)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
InstantAssetBuildPipeline,
|
InstantAssetBuildPipeline,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线 (AFBP)
|
||||||
|
/// </summary>
|
||||||
|
ArchiveFileBuildPipeline,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 17a0d1dece605b74fb10ceb9761147e9
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 归档文件构建管线(ArchiveFileBuildPipeline)的构建参数查看器
|
||||||
|
/// </summary>
|
||||||
|
[BuildPipelineAttribute(nameof(EBuildPipeline.ArchiveFileBuildPipeline))]
|
||||||
|
internal class ArchiveFileBuildPipelineViewer : BuildPipelineViewerBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 根布局容器(UXML 克隆实例)
|
||||||
|
/// </summary>
|
||||||
|
protected TemplateContainer Root;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建输出目录文本框
|
||||||
|
/// </summary>
|
||||||
|
protected TextField _buildOutputField;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建版本文本框
|
||||||
|
/// </summary>
|
||||||
|
protected TextField _buildVersionField;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源清单加密器下拉框
|
||||||
|
/// </summary>
|
||||||
|
protected PopupField<Type> _manifestEncryptorField;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源清单解密器下拉框
|
||||||
|
/// </summary>
|
||||||
|
protected PopupField<Type> _manifestDecryptorField;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 输出文件名称样式枚举字段
|
||||||
|
/// </summary>
|
||||||
|
protected EnumField _outputNameStyleField;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 首包资源拷贝选项枚举字段
|
||||||
|
/// </summary>
|
||||||
|
protected EnumField _bundledCopyOptionField;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 首包资源拷贝标签参数文本框
|
||||||
|
/// </summary>
|
||||||
|
protected TextField _bundledCopyParamField;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否清理构建缓存开关
|
||||||
|
/// </summary>
|
||||||
|
protected Toggle _clearBuildCacheToggle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否使用资源依赖数据库开关
|
||||||
|
/// </summary>
|
||||||
|
protected Toggle _useAssetDependencyDBToggle;
|
||||||
|
|
||||||
|
|
||||||
|
public override void CreateView(VisualElement parent)
|
||||||
|
{
|
||||||
|
// 加载布局文件
|
||||||
|
var visualAsset = UxmlLoader.LoadWindowUxml<ArchiveFileBuildPipelineViewer>();
|
||||||
|
if (visualAsset == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Root = visualAsset.CloneTree();
|
||||||
|
Root.style.flexGrow = 1f;
|
||||||
|
parent.Add(Root);
|
||||||
|
|
||||||
|
// 输出目录
|
||||||
|
_buildOutputField = Root.Q<TextField>("BuildOutput");
|
||||||
|
SetBuildOutputField(_buildOutputField);
|
||||||
|
|
||||||
|
// 构建版本
|
||||||
|
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
||||||
|
SetBuildVersionField(_buildVersionField);
|
||||||
|
|
||||||
|
// 清单服务
|
||||||
|
var popupContainer = Root.Q("PopupContainer");
|
||||||
|
_manifestEncryptorField = CreateManifestEncryptorField(popupContainer);
|
||||||
|
_manifestDecryptorField = CreateManifestDecryptorField(popupContainer);
|
||||||
|
|
||||||
|
// 输出文件名称样式
|
||||||
|
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||||
|
SetOutputNameStyleField(_outputNameStyleField);
|
||||||
|
|
||||||
|
// 首包资源拷贝参数
|
||||||
|
_bundledCopyParamField = Root.Q<TextField>("BundledCopyParam");
|
||||||
|
SetBundledCopyParamField(_bundledCopyParamField);
|
||||||
|
SetBundledCopyParamVisible(_bundledCopyParamField);
|
||||||
|
|
||||||
|
// 首包资源拷贝选项
|
||||||
|
_bundledCopyOptionField = Root.Q<EnumField>("BundledCopyOption");
|
||||||
|
SetBundledCopyOptionField(_bundledCopyOptionField, _bundledCopyParamField);
|
||||||
|
|
||||||
|
// 清理构建缓存
|
||||||
|
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||||
|
SetClearBuildCacheToggle(_clearBuildCacheToggle);
|
||||||
|
|
||||||
|
// 使用资源依赖数据库
|
||||||
|
_useAssetDependencyDBToggle = Root.Q<Toggle>("UseAssetDependency");
|
||||||
|
SetUseAssetDependencyDBToggle(_useAssetDependencyDBToggle);
|
||||||
|
|
||||||
|
// 构建按钮
|
||||||
|
var buildButton = Root.Q<Button>("Build");
|
||||||
|
buildButton.clicked += BuildButton_clicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildButton_clicked()
|
||||||
|
{
|
||||||
|
if (EditorUtility.DisplayDialog("Info", $"Start building resource package '{PackageName}'.", "Yes", "No"))
|
||||||
|
{
|
||||||
|
EditorWindowUtility.ClearUnityConsole();
|
||||||
|
EditorApplication.delayCall += ExecuteBuild;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("Packaging has been canceled.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行构建
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void ExecuteBuild()
|
||||||
|
{
|
||||||
|
var fileNameStyle = BundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||||
|
var bundledCopyOption = BundleBuilderSetting.GetPackageBundledCopyOption(PackageName, PipelineName);
|
||||||
|
var bundledCopyParams = BundleBuilderSetting.GetPackageBundledCopyParams(PackageName, PipelineName);
|
||||||
|
var clearBuildCache = BundleBuilderSetting.GetPackageClearBuildCache(PackageName, PipelineName);
|
||||||
|
var useAssetDependencyDB = BundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, PipelineName);
|
||||||
|
|
||||||
|
ArchiveFileBuildParameters buildParameters = new ArchiveFileBuildParameters();
|
||||||
|
buildParameters.BuildOutputRoot = BundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
|
buildParameters.BundledFileRoot = BundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
|
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||||
|
buildParameters.BuildBundleType = (int)EBundleType.ArchiveBundle;
|
||||||
|
buildParameters.BuildTarget = BuildTarget;
|
||||||
|
buildParameters.PackageName = PackageName;
|
||||||
|
buildParameters.PackageVersion = _buildVersionField.value;
|
||||||
|
buildParameters.VerifyBuildingResult = true;
|
||||||
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
|
buildParameters.BundledCopyOption = bundledCopyOption;
|
||||||
|
buildParameters.BundledCopyParams = bundledCopyParams;
|
||||||
|
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||||
|
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||||
|
buildParameters.ManifestEncryptor = CreateManifestEncryptorInstance();
|
||||||
|
buildParameters.ManifestDecryptor = CreateManifestDecryptorInstance();
|
||||||
|
|
||||||
|
ArchiveFileBuildPipeline pipeline = new ArchiveFileBuildPipeline();
|
||||||
|
var buildResult = pipeline.Run(buildParameters, true);
|
||||||
|
if (buildResult.Success)
|
||||||
|
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 31e95ed362aa6fb43ad104edf5599b89
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||||
|
<ui:VisualElement name="BuildContainer">
|
||||||
|
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||||
|
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
||||||
|
<ui:Toggle label="Clear Build Cache" name="ClearBuildCache" />
|
||||||
|
<ui:Toggle label="Use Asset Depend DB" name="UseAssetDependency" />
|
||||||
|
<ui:VisualElement name="PopupContainer" style="flex-grow: 1;" />
|
||||||
|
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
||||||
|
<uie:EnumField label="Bundled Copy Option" value="Center" name="BundledCopyOption" />
|
||||||
|
<ui:TextField picking-mode="Ignore" label="Bundled Copy Param" name="BundledCopyParam" />
|
||||||
|
<ui:VisualElement name="ExtensionContainer" />
|
||||||
|
<ui:Button text="Click Build" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||||
|
</ui:VisualElement>
|
||||||
|
</ui:UXML>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3a043220a198ef14c8656a51c520ccd3
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
@@ -30,6 +30,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected TextField _buildVersionField;
|
protected TextField _buildVersionField;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建资源包类型下拉框
|
||||||
|
/// </summary>
|
||||||
|
protected PopupField<string> _buildBundleTypeField;
|
||||||
|
|
||||||
|
|
||||||
public override void CreateView(VisualElement parent)
|
public override void CreateView(VisualElement parent)
|
||||||
{
|
{
|
||||||
@@ -50,6 +55,10 @@ namespace YooAsset.Editor
|
|||||||
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
||||||
SetBuildVersionField(_buildVersionField);
|
SetBuildVersionField(_buildVersionField);
|
||||||
|
|
||||||
|
// 构建资源包类型
|
||||||
|
var buildBundleTypeContainer = Root.Q<VisualElement>("BuildBundleType");
|
||||||
|
_buildBundleTypeField = CreateBuildBundleTypeField(buildBundleTypeContainer);
|
||||||
|
|
||||||
// 构建按钮
|
// 构建按钮
|
||||||
var buildButton = Root.Q<Button>("Build");
|
var buildButton = Root.Q<Button>("Build");
|
||||||
buildButton.clicked += BuildButton_clicked;
|
buildButton.clicked += BuildButton_clicked;
|
||||||
@@ -80,7 +89,7 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.BuildOutputRoot = BundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = BundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BundledFileRoot = BundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BundledFileRoot = BundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||||
buildParameters.BuildBundleType = (int)EBundleType.VirtualBundle;
|
buildParameters.BuildBundleType = (int)Enum.Parse(typeof(EBundleType), _buildBundleTypeField.value);
|
||||||
buildParameters.BuildTarget = BuildTarget;
|
buildParameters.BuildTarget = BuildTarget;
|
||||||
buildParameters.PackageName = PackageName;
|
buildParameters.PackageName = PackageName;
|
||||||
buildParameters.PackageVersion = _buildVersionField.value;
|
buildParameters.PackageVersion = _buildVersionField.value;
|
||||||
@@ -94,5 +103,26 @@ namespace YooAsset.Editor
|
|||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PopupField<string> CreateBuildBundleTypeField(VisualElement container)
|
||||||
|
{
|
||||||
|
var bundleTypes = Enum.GetValues(typeof(EBundleType))
|
||||||
|
.Cast<EBundleType>()
|
||||||
|
.Where(type => type.ToString().StartsWith("Virtual"))
|
||||||
|
.Select(type => type.ToString())
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
int defaultIndex = bundleTypes.IndexOf(EBundleType.VirtualAssetBundle.ToString());
|
||||||
|
if (defaultIndex < 0)
|
||||||
|
defaultIndex = 0;
|
||||||
|
|
||||||
|
var popupField = new PopupField<string>(bundleTypes, defaultIndex);
|
||||||
|
popupField.label = "Build Bundle Type";
|
||||||
|
popupField.style.width = StyleWidth;
|
||||||
|
|
||||||
|
container.Add(popupField);
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
|
||||||
|
return popupField;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
<ui:VisualElement name="BuildContainer">
|
<ui:VisualElement name="BuildContainer">
|
||||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
||||||
|
<ui:VisualElement name="BuildBundleType" />
|
||||||
<ui:VisualElement name="ExtensionContainer" />
|
<ui:VisualElement name="ExtensionContainer" />
|
||||||
<ui:Button text="Click Build" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
<ui:Button text="Click Build" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
|
|||||||
8
Assets/YooAsset/Editor/BundleCollector/AssetSearch.meta
Normal file
8
Assets/YooAsset/Editor/BundleCollector/AssetSearch.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 07c436f0dfa2bcf43b12628aed2aa91c
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 收集资源搜索结果
|
||||||
|
/// </summary>
|
||||||
|
public class CollectAssetSearchResult
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 命中的收集器分组
|
||||||
|
/// </summary>
|
||||||
|
public BundleCollectorGroup Group { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 命中的收集器分组索引
|
||||||
|
/// </summary>
|
||||||
|
public int GroupIndex { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 命中的收集器
|
||||||
|
/// </summary>
|
||||||
|
public BundleCollector Collector { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 命中的收集器索引
|
||||||
|
/// </summary>
|
||||||
|
public int CollectorIndex { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 命中的资源路径
|
||||||
|
/// </summary>
|
||||||
|
public string AssetPath { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建收集资源搜索结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="group">命中的收集器分组</param>
|
||||||
|
/// <param name="groupIndex">命中的收集器分组索引</param>
|
||||||
|
/// <param name="collector">命中的收集器</param>
|
||||||
|
/// <param name="collectorIndex">命中的收集器索引</param>
|
||||||
|
/// <param name="assetPath">命中的资源路径</param>
|
||||||
|
public CollectAssetSearchResult(BundleCollectorGroup group, int groupIndex,
|
||||||
|
BundleCollector collector, int collectorIndex, string assetPath)
|
||||||
|
{
|
||||||
|
Group = group;
|
||||||
|
GroupIndex = groupIndex;
|
||||||
|
Collector = collector;
|
||||||
|
CollectorIndex = collectorIndex;
|
||||||
|
AssetPath = assetPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ff1a09e6aca8b104c9b256885b06130f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 收集资源搜索工具类
|
||||||
|
/// </summary>
|
||||||
|
public static class CollectAssetSearchUtility
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 验证搜索路径
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">搜索路径</param>
|
||||||
|
/// <returns>搜索路径错误类型</returns>
|
||||||
|
public static ECollectAssetSearchError ValidateSearchPath(string input)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(input))
|
||||||
|
return ECollectAssetSearchError.InputPathEmpty;
|
||||||
|
|
||||||
|
if (input.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase) == false)
|
||||||
|
return ECollectAssetSearchError.InputPathMissingAssetsPrefix;
|
||||||
|
|
||||||
|
if (input.EndsWith("/"))
|
||||||
|
return ECollectAssetSearchError.InputPathEndsWithSlash;
|
||||||
|
|
||||||
|
string fileName = System.IO.Path.GetFileName(input);
|
||||||
|
if (fileName.Contains(".") == false)
|
||||||
|
return ECollectAssetSearchError.InputPathMissingExtension;
|
||||||
|
|
||||||
|
if (AssetDatabase.IsValidFolder(input))
|
||||||
|
return ECollectAssetSearchError.InputPathIsFolder;
|
||||||
|
|
||||||
|
string guid = AssetDatabase.AssetPathToGUID(input);
|
||||||
|
if (string.IsNullOrEmpty(guid))
|
||||||
|
return ECollectAssetSearchError.AssetPathNotExists;
|
||||||
|
|
||||||
|
return ECollectAssetSearchError.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取搜索路径错误提示信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="error">搜索路径错误类型</param>
|
||||||
|
/// <param name="input">搜索路径</param>
|
||||||
|
/// <returns>错误提示信息</returns>
|
||||||
|
public static string GetSearchPathErrorMessage(ECollectAssetSearchError error, string input)
|
||||||
|
{
|
||||||
|
switch (error)
|
||||||
|
{
|
||||||
|
case ECollectAssetSearchError.InputPathEmpty:
|
||||||
|
return "Please enter an asset path.";
|
||||||
|
case ECollectAssetSearchError.InputPathMissingAssetsPrefix:
|
||||||
|
return "Path must start with Assets/.";
|
||||||
|
case ECollectAssetSearchError.InputPathEndsWithSlash:
|
||||||
|
return "Please enter a file path. Do not end with /.";
|
||||||
|
case ECollectAssetSearchError.InputPathMissingExtension:
|
||||||
|
return "Path is missing a file extension (e.g. .prefab, .png, .mat).";
|
||||||
|
case ECollectAssetSearchError.InputPathIsFolder:
|
||||||
|
return "Please enter an asset file path, not a folder path.";
|
||||||
|
case ECollectAssetSearchError.AssetPathNotExists:
|
||||||
|
return $"Asset not found: {input}";
|
||||||
|
default:
|
||||||
|
return "Invalid input format.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 在指定 Package 中搜索资源路径,找到第一个命中结果即返回
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="package">搜索的资源包裹</param>
|
||||||
|
/// <param name="assetPath">资源路径</param>
|
||||||
|
/// <returns>搜索结果,如果未找到返回 null</returns>
|
||||||
|
public static CollectAssetSearchResult SearchAssetPath(BundleCollectorPackage package, string assetPath)
|
||||||
|
{
|
||||||
|
if (ValidateSearchPath(assetPath) != ECollectAssetSearchError.None)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IAssetIgnoreRule ignoreRule = BundleCollectorSettingData.GetAssetIgnoreRuleInstance(package.IgnoreRuleName);
|
||||||
|
var command = new CollectCommand(package.PackageName, ignoreRule);
|
||||||
|
command.SetFlag(ECollectFlags.IgnoreGetDependencies, true);
|
||||||
|
command.UniqueBundleName = BundleCollectorSettingData.Setting.UniqueBundleName;
|
||||||
|
command.EnableAddressable = package.EnableAddressable;
|
||||||
|
command.SupportExtensionless = package.SupportExtensionless;
|
||||||
|
command.LocationToLower = package.LocationToLower;
|
||||||
|
command.IncludeAssetGUID = package.IncludeAssetGUID;
|
||||||
|
command.AutoCollectShaders = package.AutoCollectShaders;
|
||||||
|
|
||||||
|
for (int groupIndex = 0; groupIndex < package.Groups.Count; groupIndex++)
|
||||||
|
{
|
||||||
|
var group = package.Groups[groupIndex];
|
||||||
|
for (int collectIndex = 0; collectIndex < group.Collectors.Count; collectIndex++)
|
||||||
|
{
|
||||||
|
var collector = group.Collectors[collectIndex];
|
||||||
|
|
||||||
|
// 判断收集器是否可能收集指定资源
|
||||||
|
if (IsCandidateCollector(collector, assetPath) == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 检测配置是否有效
|
||||||
|
collector.CheckConfigError();
|
||||||
|
|
||||||
|
// 收集有效资源信息
|
||||||
|
var collectAssets = collector.GetAllCollectAssets(command, group);
|
||||||
|
foreach (var collectAsset in collectAssets)
|
||||||
|
{
|
||||||
|
if (string.Equals(collectAsset.AssetInfo.AssetPath, assetPath, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return new CollectAssetSearchResult(group, groupIndex, collector, collectIndex, assetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Invalid collector : {collector.CollectPath}, error: {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 未找到匹配资源
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断收集器是否可能收集指定资源
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collector">收集器</param>
|
||||||
|
/// <param name="assetPath">资源路径</param>
|
||||||
|
/// <returns>如果收集器可能收集该资源返回 true</returns>
|
||||||
|
private static bool IsCandidateCollector(BundleCollector collector, string assetPath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(collector.CollectPath))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (AssetDatabase.IsValidFolder(collector.CollectPath))
|
||||||
|
{
|
||||||
|
string folderPath = collector.CollectPath.TrimEnd('/') + "/";
|
||||||
|
return assetPath.StartsWith(folderPath, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注意:资源收集器也可能直接配置的单个资源路径
|
||||||
|
return string.Equals(assetPath, collector.CollectPath, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6c8bc2931bda7884198893f1d2e8f364
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 搜索错误类型
|
||||||
|
/// </summary>
|
||||||
|
public enum ECollectAssetSearchError
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 无错误
|
||||||
|
/// </summary>
|
||||||
|
None,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 输入路径为空
|
||||||
|
/// </summary>
|
||||||
|
InputPathEmpty,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 输入路径缺少 Assets/ 路径前缀
|
||||||
|
/// </summary>
|
||||||
|
InputPathMissingAssetsPrefix,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 输入路径以斜杠结尾
|
||||||
|
/// </summary>
|
||||||
|
InputPathEndsWithSlash,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 输入路径缺少文件扩展名
|
||||||
|
/// </summary>
|
||||||
|
InputPathMissingExtension,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 输入路径的是文件夹路径
|
||||||
|
/// </summary>
|
||||||
|
InputPathIsFolder,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源文件不存在
|
||||||
|
/// </summary>
|
||||||
|
AssetPathNotExists,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9a2c8a878d6041b4d8bad2a2d2f1896d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -60,21 +60,22 @@ namespace YooAsset.Editor
|
|||||||
/// <returns>如果收集器配置有效返回 true</returns>
|
/// <returns>如果收集器配置有效返回 true</returns>
|
||||||
public bool IsValid()
|
public bool IsValid()
|
||||||
{
|
{
|
||||||
if (AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(CollectPath) == null)
|
string assetGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||||
|
if (string.IsNullOrEmpty(assetGUID))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (CollectorType == ECollectorType.None)
|
if (CollectorType == ECollectorType.None)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (BundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (BundleCollectorSettingData.HasBundlePackRuleName(PackRuleName) == false)
|
if (BundleCollectorSettingData.HasBundlePackRuleName(PackRuleName) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (BundleCollectorSettingData.HasAssetFilterRuleName(FilterRuleName) == false)
|
if (BundleCollectorSettingData.HasAssetFilterRuleName(FilterRuleName) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (BundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace YooAsset.Editor
|
|||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const string PlaceholderClass = "search-placeholder";
|
||||||
|
|
||||||
private Button _saveButton;
|
private Button _saveButton;
|
||||||
private List<string> _collectorTypeList;
|
private List<string> _collectorTypeList;
|
||||||
private List<RuleDisplayName> _groupActiveRuleList;
|
private List<RuleDisplayName> _groupActiveRuleList;
|
||||||
@@ -35,6 +37,11 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
private VisualElement _helpBoxContainer;
|
private VisualElement _helpBoxContainer;
|
||||||
|
|
||||||
|
private ToolbarSearchField _searchField;
|
||||||
|
private TextField _searchTextField;
|
||||||
|
private Button _searchButton;
|
||||||
|
private Label _searchResultLabel;
|
||||||
|
|
||||||
private Button _globalSettingsButton;
|
private Button _globalSettingsButton;
|
||||||
private Button _packageSettingsButton;
|
private Button _packageSettingsButton;
|
||||||
|
|
||||||
@@ -66,6 +73,8 @@ namespace YooAsset.Editor
|
|||||||
private ScrollView _collectorScrollView;
|
private ScrollView _collectorScrollView;
|
||||||
private PopupField<RuleDisplayName> _activeRulePopupField;
|
private PopupField<RuleDisplayName> _activeRulePopupField;
|
||||||
|
|
||||||
|
private string _highlightAssetPath;
|
||||||
|
private int _highlightCollectorIndex = -1;
|
||||||
private int _lastModifyPackageIndex = 0;
|
private int _lastModifyPackageIndex = 0;
|
||||||
private int _lastModifyGroupIndex = 0;
|
private int _lastModifyGroupIndex = 0;
|
||||||
private bool _showGlobalSettings = false;
|
private bool _showGlobalSettings = false;
|
||||||
@@ -219,6 +228,44 @@ namespace YooAsset.Editor
|
|||||||
_saveButton = root.Q<Button>("SaveButton");
|
_saveButton = root.Q<Button>("SaveButton");
|
||||||
_saveButton.clicked += OnSaveButtonClicked;
|
_saveButton.clicked += OnSaveButtonClicked;
|
||||||
|
|
||||||
|
// 搜索相关
|
||||||
|
_searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||||
|
_searchTextField = _searchField.Q<TextField>();
|
||||||
|
_searchTextField.RegisterCallback<FocusInEvent>(evt =>
|
||||||
|
{
|
||||||
|
if (_searchTextField.ClassListContains(PlaceholderClass))
|
||||||
|
{
|
||||||
|
_searchField.value = string.Empty;
|
||||||
|
ClearSearchPlaceholder();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_searchTextField.RegisterCallback<FocusOutEvent>(evt =>
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_searchField.value))
|
||||||
|
ApplySearchPlaceholder();
|
||||||
|
});
|
||||||
|
_searchField.RegisterCallback<DragUpdatedEvent>(evt =>
|
||||||
|
{
|
||||||
|
if (DragAndDrop.objectReferences.Length > 0)
|
||||||
|
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
|
||||||
|
});
|
||||||
|
_searchField.RegisterCallback<DragPerformEvent>(evt =>
|
||||||
|
{
|
||||||
|
if (DragAndDrop.objectReferences.Length > 0)
|
||||||
|
{
|
||||||
|
string assetPath = AssetDatabase.GetAssetPath(DragAndDrop.objectReferences[0]);
|
||||||
|
if (string.IsNullOrEmpty(assetPath) == false)
|
||||||
|
{
|
||||||
|
_searchField.value = assetPath;
|
||||||
|
ClearSearchPlaceholder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ApplySearchPlaceholder();
|
||||||
|
_searchButton = root.Q<Button>("SearchButton");
|
||||||
|
_searchButton.clicked += OnSearchButtonClicked;
|
||||||
|
_searchResultLabel = root.Q<Label>("SearchResultLabel");
|
||||||
|
|
||||||
// 包裹容器
|
// 包裹容器
|
||||||
_packageContainer = root.Q("PackageContainer");
|
_packageContainer = root.Q("PackageContainer");
|
||||||
|
|
||||||
@@ -423,6 +470,8 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
private void RefreshWindow()
|
private void RefreshWindow()
|
||||||
{
|
{
|
||||||
|
_highlightAssetPath = null;
|
||||||
|
_highlightCollectorIndex = -1;
|
||||||
_groupContainer.visible = false;
|
_groupContainer.visible = false;
|
||||||
_collectorContainer.visible = false;
|
_collectorContainer.visible = false;
|
||||||
|
|
||||||
@@ -455,6 +504,54 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
BundleCollectorSettingData.SaveFile();
|
BundleCollectorSettingData.SaveFile();
|
||||||
}
|
}
|
||||||
|
private void OnSearchButtonClicked()
|
||||||
|
{
|
||||||
|
_highlightAssetPath = null;
|
||||||
|
_highlightCollectorIndex = -1;
|
||||||
|
FillCollectorViewData();
|
||||||
|
|
||||||
|
string searchInput = GetSearchInput();
|
||||||
|
var pathError = CollectAssetSearchUtility.ValidateSearchPath(searchInput);
|
||||||
|
if (pathError != ECollectAssetSearchError.None)
|
||||||
|
{
|
||||||
|
string message = CollectAssetSearchUtility.GetSearchPathErrorMessage(pathError, searchInput);
|
||||||
|
ShowSearchResult(message, new Color(1f, 0.4f, 0.4f));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var selectPackage = _packageListView.selectedItem as BundleCollectorPackage;
|
||||||
|
if (selectPackage == null)
|
||||||
|
{
|
||||||
|
string message = "No package selected. Please select a package first.";
|
||||||
|
ShowSearchResult(message, new Color(1f, 0.8f, 0.3f));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var searchResult = CollectAssetSearchUtility.SearchAssetPath(selectPackage, searchInput);
|
||||||
|
if (searchResult == null)
|
||||||
|
{
|
||||||
|
string message = $"No results found in package '{selectPackage.PackageName}'.";
|
||||||
|
ShowSearchResult(message, new Color(1f, 0.8f, 0.3f));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string resultMessage = $"Found in group '{searchResult.Group.GroupName}', collector '{searchResult.Collector.CollectPath}'";
|
||||||
|
ShowSearchResult(resultMessage, Color.white);
|
||||||
|
|
||||||
|
_searchResultLabel.style.unityFontStyleAndWeight = FontStyle.Bold;
|
||||||
|
_searchResultLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
|
||||||
|
_highlightAssetPath = searchResult.AssetPath;
|
||||||
|
_highlightCollectorIndex = searchResult.CollectorIndex;
|
||||||
|
|
||||||
|
_groupContainer.visible = true;
|
||||||
|
_lastModifyGroupIndex = searchResult.GroupIndex;
|
||||||
|
|
||||||
|
if (_groupListView.selectedIndex == searchResult.GroupIndex)
|
||||||
|
FillCollectorViewData();
|
||||||
|
else
|
||||||
|
_groupListView.selectedIndex = searchResult.GroupIndex;
|
||||||
|
}
|
||||||
private void OnGlobalSettingsButtonClicked()
|
private void OnGlobalSettingsButtonClicked()
|
||||||
{
|
{
|
||||||
_showGlobalSettings = !_showGlobalSettings;
|
_showGlobalSettings = !_showGlobalSettings;
|
||||||
@@ -480,6 +577,45 @@ namespace YooAsset.Editor
|
|||||||
return ruleDisplayName.ClassName;
|
return ruleDisplayName.ClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 搜索栏相关
|
||||||
|
private void ShowSearchResult(string message, Color color)
|
||||||
|
{
|
||||||
|
_searchResultLabel.text = message;
|
||||||
|
_searchResultLabel.style.color = color;
|
||||||
|
_searchResultLabel.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||||
|
_searchResultLabel.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||||
|
_searchResultLabel.style.display = DisplayStyle.Flex;
|
||||||
|
}
|
||||||
|
private void ClearSearchResult()
|
||||||
|
{
|
||||||
|
_searchResultLabel.text = string.Empty;
|
||||||
|
_searchResultLabel.style.display = DisplayStyle.None;
|
||||||
|
}
|
||||||
|
private void ApplySearchPlaceholder()
|
||||||
|
{
|
||||||
|
_searchField.value = "Drag or enter asset path here (e.g. Assets/Res/icon.png)";
|
||||||
|
if (_searchTextField.ClassListContains(PlaceholderClass) == false)
|
||||||
|
_searchTextField.AddToClassList(PlaceholderClass);
|
||||||
|
|
||||||
|
var inputElement = _searchTextField.Q("unity-text-input");
|
||||||
|
inputElement.style.color = new Color(0.7f, 0.7f, 0.7f, 0.6f);
|
||||||
|
}
|
||||||
|
private void ClearSearchPlaceholder()
|
||||||
|
{
|
||||||
|
if (_searchTextField.ClassListContains(PlaceholderClass))
|
||||||
|
{
|
||||||
|
_searchTextField.RemoveFromClassList(PlaceholderClass);
|
||||||
|
var inputElement = _searchTextField.Q("unity-text-input");
|
||||||
|
inputElement.style.color = StyleKeyword.Null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private string GetSearchInput()
|
||||||
|
{
|
||||||
|
if (_searchTextField.ClassListContains(PlaceholderClass))
|
||||||
|
return string.Empty;
|
||||||
|
return _searchField.value;
|
||||||
|
}
|
||||||
|
|
||||||
// 设置栏相关
|
// 设置栏相关
|
||||||
private void RefreshSettings()
|
private void RefreshSettings()
|
||||||
{
|
{
|
||||||
@@ -607,6 +743,8 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private void OnPackageListViewSelectionChange(IEnumerable<object> objs)
|
private void OnPackageListViewSelectionChange(IEnumerable<object> objs)
|
||||||
{
|
{
|
||||||
|
ClearSearchResult();
|
||||||
|
|
||||||
var selectPackage = _packageListView.selectedItem as BundleCollectorPackage;
|
var selectPackage = _packageListView.selectedItem as BundleCollectorPackage;
|
||||||
if (selectPackage == null)
|
if (selectPackage == null)
|
||||||
{
|
{
|
||||||
@@ -752,6 +890,15 @@ namespace YooAsset.Editor
|
|||||||
BindCollectorListViewItem(element, i);
|
BindCollectorListViewItem(element, i);
|
||||||
_collectorScrollView.Add(element);
|
_collectorScrollView.Add(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_highlightCollectorIndex >= 0 && _highlightCollectorIndex < selectGroup.Collectors.Count)
|
||||||
|
{
|
||||||
|
var targetElement = _collectorScrollView[_highlightCollectorIndex];
|
||||||
|
var foldout = targetElement.Q<Foldout>("Foldout1");
|
||||||
|
if (foldout != null)
|
||||||
|
foldout.value = true;
|
||||||
|
_highlightCollectorIndex = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private VisualElement MakeCollectorListViewItem()
|
private VisualElement MakeCollectorListViewItem()
|
||||||
{
|
{
|
||||||
@@ -1033,13 +1180,6 @@ namespace YooAsset.Editor
|
|||||||
// 清空旧元素
|
// 清空旧元素
|
||||||
foldout.Clear();
|
foldout.Clear();
|
||||||
|
|
||||||
// 检测配置是否有效
|
|
||||||
if (collector.IsValid() == false)
|
|
||||||
{
|
|
||||||
collector.CheckConfigError();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<CollectAssetInfo> collectAssetInfos = null;
|
List<CollectAssetInfo> collectAssetInfos = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -1055,12 +1195,15 @@ namespace YooAsset.Editor
|
|||||||
command.IncludeAssetGUID = _includeAssetGUIDToggle.value;
|
command.IncludeAssetGUID = _includeAssetGUIDToggle.value;
|
||||||
command.AutoCollectShaders = _autoCollectShadersToggle.value;
|
command.AutoCollectShaders = _autoCollectShadersToggle.value;
|
||||||
|
|
||||||
|
// 检测配置是否有效
|
||||||
collector.CheckConfigError();
|
collector.CheckConfigError();
|
||||||
|
|
||||||
|
// 收集有效资源信息
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.LogError(e.ToString());
|
Debug.LogError($"Invalid collector : {collector.CollectPath}, error: {e.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collectAssetInfos != null)
|
if (collectAssetInfos != null)
|
||||||
@@ -1085,6 +1228,13 @@ namespace YooAsset.Editor
|
|||||||
label.style.width = 300;
|
label.style.width = 300;
|
||||||
label.style.marginLeft = 0;
|
label.style.marginLeft = 0;
|
||||||
label.style.flexGrow = 1;
|
label.style.flexGrow = 1;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_highlightAssetPath) == false &&
|
||||||
|
string.Equals(collectAsset.AssetInfo.AssetPath, _highlightAssetPath, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
label.style.color = new Color(1f, 0.2f, 0.2f);
|
||||||
|
}
|
||||||
|
|
||||||
elementRow.Add(label);
|
elementRow.Add(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,11 @@
|
|||||||
<ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
<ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||||
<ui:Button text="Fix" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
<ui:Button text="Fix" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
|
<uie:Toolbar name="SearchToolbar" style="display: flex; flex-direction: row;">
|
||||||
|
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
||||||
|
<ui:Button text="Search" display-tooltip-when-elided="true" name="SearchButton" style="width: 60px; background-color: rgb(56, 147, 58);" />
|
||||||
|
</uie:Toolbar>
|
||||||
|
<ui:Label name="SearchResultLabel" style="display: none; height: 24px; -unity-text-align: middle-center; padding-left: 5px; padding-right: 5px;" />
|
||||||
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
<ui:VisualElement name="HelpBoxContainer" style="flex-grow: 1;" />
|
<ui:VisualElement name="HelpBoxContainer" style="flex-grow: 1;" />
|
||||||
<ui:VisualElement name="GlobalSettingsContainer">
|
<ui:VisualElement name="GlobalSettingsContainer">
|
||||||
|
|||||||
@@ -73,5 +73,12 @@ namespace YooAsset
|
|||||||
/// <param name="bundleGuid">资源包的唯一标识符</param>
|
/// <param name="bundleGuid">资源包的唯一标识符</param>
|
||||||
/// <returns>如果缓存中存在该资源包则返回 true,否则返回 false。</returns>
|
/// <returns>如果缓存中存在该资源包则返回 true,否则返回 false。</returns>
|
||||||
bool IsCached(string bundleGuid);
|
bool IsCached(string bundleGuid);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取已缓存的资源包文件路径
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bundleGuid">资源包的唯一标识符</param>
|
||||||
|
/// <returns>返回已缓存的资源包文件路径,如果不存在则返回 null。</returns>
|
||||||
|
string GetCacheFilePath(string bundleGuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace YooAsset
|
|||||||
internal interface ICacheEntry
|
internal interface ICacheEntry
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bundle 唯一标识
|
/// 资源包唯一标识
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string BundleGuid { get; }
|
string BundleGuid { get; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理缓存操作选项
|
/// 清理缓存的操作选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal readonly struct BCClearCacheOptions
|
internal readonly struct BCClearCacheOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载资源包操作选项
|
/// 加载资源包的操作选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal readonly struct BCLoadBundleOptions
|
internal readonly struct BCLoadBundleOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证缓存操作选项
|
/// 验证缓存的操作选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal readonly struct BCVerifyCacheOptions
|
internal readonly struct BCVerifyCacheOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 写入缓存操作选项
|
/// 写入缓存的操作选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal readonly struct BCWriteCacheOptions
|
internal readonly struct BCWriteCacheOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建加载内置资源目录操作实例
|
/// 创建加载内置资源目录操作实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="options">加载内置资源目录的配置选项</param>
|
/// <param name="options">加载内置资源目录的操作选项</param>
|
||||||
internal LoadBuiltinCatalogOperation(LoadBuiltinCatalogOptions options)
|
internal LoadBuiltinCatalogOperation(LoadBuiltinCatalogOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载内置资源目录操作选项
|
/// 加载内置资源目录的操作选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal readonly struct LoadBuiltinCatalogOptions
|
internal readonly struct LoadBuiltinCatalogOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 从本地加载 ArchiveBundle 操作
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class LoadLocalArchiveBundleOperation : BCLoadBundleOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
LoadBundle,
|
||||||
|
CheckResult,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly LoadLocalArchiveBundleOptions _options;
|
||||||
|
private ArchiveBundle _archiveBundle;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建本地 ArchiveBundle 加载操作实例
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options">从本地加载 ArchiveBundle 的操作选项</param>
|
||||||
|
public LoadLocalArchiveBundleOperation(LoadLocalArchiveBundleOptions options)
|
||||||
|
{
|
||||||
|
_options = options;
|
||||||
|
}
|
||||||
|
protected override void InternalStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadBundle;
|
||||||
|
}
|
||||||
|
protected override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadBundle)
|
||||||
|
{
|
||||||
|
if (_options.Bundle.IsEncrypted)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
SetError($"ArchiveBundle encrypted loading is not supported: '{_options.FilePath}'.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FileUtility.IsFileIOSupported(_options.FilePath) == false)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
SetError($"FileIO is not supported for builtin path: '{_options.FilePath}'.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadResult result = ParseArchiveFile();
|
||||||
|
if (result.Succeeded == false)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
SetError(result.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_steps = ESteps.CheckResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckResult)
|
||||||
|
{
|
||||||
|
if (_archiveBundle == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
SetError($"Loaded archive bundle is null.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
SetResult();
|
||||||
|
BundleHandle = new ArchiveBundleHandle(_options.Bundle, _archiveBundle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected override void InternalWaitForCompletion()
|
||||||
|
{
|
||||||
|
ExecuteBatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
private LoadResult ParseArchiveFile()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_archiveBundle = ArchiveBundleHelper.LoadArchiveBundle(_options.FilePath);
|
||||||
|
return LoadResult.Default();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return LoadResult.Failure($"Failed to parse archive file: {ex.Message}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2bda507c0443af147bc0f8999f5b1229
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 加载 ArchiveBundle 的操作选项
|
||||||
|
/// </summary>
|
||||||
|
internal readonly struct LoadLocalArchiveBundleOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件缓存名称
|
||||||
|
/// </summary>
|
||||||
|
public string CacheName { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包描述
|
||||||
|
/// </summary>
|
||||||
|
public PackageBundle Bundle { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件加载路径
|
||||||
|
/// </summary>
|
||||||
|
public string FilePath { get; }
|
||||||
|
|
||||||
|
public LoadLocalArchiveBundleOptions(string cacheName, PackageBundle bundle, string filePath)
|
||||||
|
{
|
||||||
|
CacheName = cacheName;
|
||||||
|
Bundle = bundle;
|
||||||
|
FilePath = filePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cb278952b9622084da5b2515b095aef8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -30,7 +30,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建本地 AssetBundle 加载操作实例
|
/// 创建本地 AssetBundle 加载操作实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="options">从本地加载 AssetBundle 的配置选项</param>
|
/// <param name="options">从本地加载 AssetBundle 的操作选项</param>
|
||||||
public LoadLocalAssetBundleOperation(LoadLocalAssetBundleOptions options)
|
public LoadLocalAssetBundleOperation(LoadLocalAssetBundleOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
@@ -121,7 +121,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
SetResult();
|
SetResult();
|
||||||
BundleHandle = new AssetBundleHandle(_options.FilePath, _options.Bundle, _assetBundle, _loadStream);
|
BundleHandle = new AssetBundleHandle(_options.Bundle, _assetBundle, _loadStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载 AssetBundle 的上下文信息
|
/// 加载 AssetBundle 的操作选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal readonly struct LoadLocalAssetBundleOptions
|
internal readonly struct LoadLocalAssetBundleOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建本地 RawBundle 加载操作实例
|
/// 创建本地 RawBundle 加载操作实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="options">从本地加载 RawBundle 的配置选项</param>
|
/// <param name="options">从本地加载 RawBundle 的操作选项</param>
|
||||||
public LoadLocalRawBundleOperation(LoadLocalRawBundleOptions options)
|
public LoadLocalRawBundleOperation(LoadLocalRawBundleOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
@@ -100,7 +100,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
SetResult();
|
SetResult();
|
||||||
BundleHandle = new RawBundleHandle(_options.FilePath, _options.Bundle, _rawBundle);
|
BundleHandle = new RawBundleHandle(_options.Bundle, _rawBundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载 RawBundle 的上下文信息
|
/// 加载 RawBundle 的操作选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal readonly struct LoadLocalRawBundleOptions
|
internal readonly struct LoadLocalRawBundleOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ namespace YooAsset
|
|||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建 LoadWebNormalAssetBundleOperation 实例
|
/// 创建 AssetBundle 加载操作实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="options">从网络加载 AssetBundle 的配置选项</param>
|
/// <param name="options">从网络加载 AssetBundle 的操作选项</param>
|
||||||
public LoadWebNormalAssetBundleOperation(LoadWebAssetBundleOptions options)
|
public LoadWebNormalAssetBundleOperation(LoadWebAssetBundleOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
@@ -75,7 +75,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
SetResult();
|
SetResult();
|
||||||
BundleHandle = new AssetBundleHandle(_downloadAssetBundleRequest.Url, _options.Bundle, assetBundle, null);
|
BundleHandle = new AssetBundleHandle(_options.Bundle, assetBundle, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -133,6 +133,7 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
Prepare,
|
||||||
DataRequest,
|
DataRequest,
|
||||||
CheckRequest,
|
CheckRequest,
|
||||||
VerifyData,
|
VerifyData,
|
||||||
@@ -150,9 +151,9 @@ namespace YooAsset
|
|||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建 LoadWebEncryptedAssetBundleOperation 实例
|
/// 创建网络 AssetBundle 加载操作实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="options">从网络加载 AssetBundle 的配置选项</param>
|
/// <param name="options">从网络加载 AssetBundle 的操作选项</param>
|
||||||
public LoadWebEncryptedAssetBundleOperation(LoadWebAssetBundleOptions options)
|
public LoadWebEncryptedAssetBundleOperation(LoadWebAssetBundleOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
@@ -162,26 +163,38 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
protected override void InternalStart()
|
protected override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.DataRequest;
|
_steps = ESteps.Prepare;
|
||||||
}
|
}
|
||||||
protected override void InternalUpdate()
|
protected override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.DataRequest)
|
if (_steps == ESteps.Prepare)
|
||||||
{
|
{
|
||||||
var decryptor = _options.AssetBundleDecryptor;
|
var decryptor = _options.AssetBundleDecryptor;
|
||||||
if (decryptor == null)
|
if (decryptor == null)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
SetError($"{_options.CacheName} decryptor is null.");
|
SetError($"{_options.CacheName} asset bundle decryptor is null.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decryptor is IBundleMemoryDecryptor)
|
if (decryptor is IBundleMemoryDecryptor)
|
||||||
{
|
{
|
||||||
_decryptor = decryptor as IBundleMemoryDecryptor;
|
_decryptor = decryptor as IBundleMemoryDecryptor;
|
||||||
|
_steps = ESteps.DataRequest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
SetError($"{_options.CacheName} does not support '{decryptor.GetType().Name}'.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.DataRequest)
|
||||||
|
{
|
||||||
string url = _options.DownloadUrlPolicy.SelectUrl(_options.CandidateUrls);
|
string url = _options.DownloadUrlPolicy.SelectUrl(_options.CandidateUrls);
|
||||||
var args = new DownloadDataRequestArgs(
|
var args = new DownloadDataRequestArgs(
|
||||||
url: url,
|
url: url,
|
||||||
@@ -191,13 +204,6 @@ namespace YooAsset
|
|||||||
_downloadBytesRequest.SendRequest();
|
_downloadBytesRequest.SendRequest();
|
||||||
_steps = ESteps.CheckRequest;
|
_steps = ESteps.CheckRequest;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
SetError($"{_options.CacheName} does not support '{decryptor.GetType().Name}'.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.CheckRequest)
|
if (_steps == ESteps.CheckRequest)
|
||||||
{
|
{
|
||||||
@@ -225,6 +231,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
SetError(_downloadBytesRequest.Error);
|
SetError(_downloadBytesRequest.Error);
|
||||||
|
YooLogger.LogError(Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,7 +253,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string error = $"[WebBundleVerify] Verify failed. Url: '{_downloadBytesRequest.Url}' Level: {_options.DownloadVerifyLevel} Result: {verifyResult}.";
|
string error = $"Verify failed. Url: '{_downloadBytesRequest.Url}' Level: {_options.DownloadVerifyLevel} Result: {verifyResult}.";
|
||||||
YooLogger.LogWarning(error);
|
YooLogger.LogWarning(error);
|
||||||
|
|
||||||
if (IsWaitForCompletion == false && _downloadRetryController.HasRetriesRemaining())
|
if (IsWaitForCompletion == false && _downloadRetryController.HasRetriesRemaining())
|
||||||
@@ -290,7 +297,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
SetResult();
|
SetResult();
|
||||||
BundleHandle = new AssetBundleHandle(_downloadBytesRequest.Url, _options.Bundle, assetBundle, null);
|
BundleHandle = new AssetBundleHandle(_options.Bundle, assetBundle, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载 AssetBundle 的上下文信息
|
/// 加载 AssetBundle 的操作选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal readonly struct LoadWebAssetBundleOptions
|
internal readonly struct LoadWebAssetBundleOptions
|
||||||
{
|
{
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user