Compare commits
30 Commits
1.4.6-prev
...
1.4.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39ffad6da6 | ||
|
|
13924fca13 | ||
|
|
438f006d1d | ||
|
|
6fb5626230 | ||
|
|
ab29069af5 | ||
|
|
fc3ed28eda | ||
|
|
46c9110b85 | ||
|
|
06b033ed36 | ||
|
|
ab96f3f28c | ||
|
|
295238cbb6 | ||
|
|
4f0f0e54ac | ||
|
|
a9a01b08dc | ||
|
|
c27a3e105c | ||
|
|
3cfc084e62 | ||
|
|
7c1873e861 | ||
|
|
c57c313dbe | ||
|
|
19cf9c0129 | ||
|
|
ebcb05cc55 | ||
|
|
7c4dbb1f38 | ||
|
|
091b46ccaf | ||
|
|
4da2bf441f | ||
|
|
365ed560f6 | ||
|
|
bcf6372602 | ||
|
|
a5e24be5d4 | ||
|
|
cdaf6f0dca | ||
|
|
e38d0bc6d0 | ||
|
|
eb16ba8365 | ||
|
|
3beb4f53d6 | ||
|
|
f8ba0c9753 | ||
|
|
0232e5adec |
@@ -2,6 +2,41 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [1.4.7] - 2023-03-03
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了在运行时资源引用链无效的问题。
|
||||||
|
- 修复了在构建过程中发生异常后进度条未消失的问题。
|
||||||
|
- 修复了使用SBP构建管线,如果有原生文件会导致打包失败的问题。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 支持自定义下载请求
|
||||||
|
|
||||||
|
```c#
|
||||||
|
/// <summary>
|
||||||
|
/// 设置下载系统参数,自定义下载请求
|
||||||
|
/// </summary>
|
||||||
|
public static void SetDownloadSystemUnityWebRequest(DownloadRequestDelegate requestDelegate)
|
||||||
|
```
|
||||||
|
|
||||||
|
- 优化了打包时资源包引用关系计算的逻辑。
|
||||||
|
|
||||||
|
- 优化了缓存系统初始化逻辑,支持分帧获取所有缓存文件。
|
||||||
|
|
||||||
|
- 优化了缓存系统的存储目录结构,提高了文件夹查询速度。
|
||||||
|
|
||||||
|
- 优化了在资源收集界面,点击查看Collector主资源列表卡顿问题。
|
||||||
|
|
||||||
|
- 优化了资源对象加载耗时统计的逻辑,现在更加准确了。
|
||||||
|
|
||||||
|
- 优化了资源加载器查询逻辑。
|
||||||
|
|
||||||
|
- 优化了资源下载系统,下载文件的验证支持了多线程。
|
||||||
|
|
||||||
|
- 着色器变种收集界面增加单次照射数量的控制。
|
||||||
|
|
||||||
## [1.4.6-preview] - 2023-02-22
|
## [1.4.6-preview] - 2023-02-22
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 是否显示LOG
|
// 是否显示LOG
|
||||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
BuildRunner.EnableLog = false;
|
BuildLogger.EnableLog = false;
|
||||||
else
|
else
|
||||||
BuildRunner.EnableLog = true;
|
BuildLogger.EnableLog = true;
|
||||||
|
|
||||||
// 创建构建节点
|
// 创建构建节点
|
||||||
List<IBuildTask> pipeline;
|
List<IBuildTask> pipeline;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 加密服务类
|
// 加密服务类
|
||||||
_encryptionServicesClassTypes = GetEncryptionServicesClassTypes();
|
_encryptionServicesClassTypes = GetEncryptionServicesClassTypes();
|
||||||
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToList();
|
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.Name).ToList();
|
||||||
|
|
||||||
// 输出目录
|
// 输出目录
|
||||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildRunner.Log($"发现未被依赖的资源并自动移除 : {dependAssetPath}");
|
BuildLogger.Log($"发现未被依赖的资源并自动移除 : {dependAssetPath}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class BuildParametersContext : IContextObject
|
public class BuildParametersContext : IContextObject
|
||||||
{
|
{
|
||||||
private readonly System.Diagnostics.Stopwatch _buildWatch = new System.Diagnostics.Stopwatch();
|
|
||||||
|
|
||||||
private string _pipelineOutputDirectory = string.Empty;
|
private string _pipelineOutputDirectory = string.Empty;
|
||||||
private string _packageOutputDirectory = string.Empty;
|
private string _packageOutputDirectory = string.Empty;
|
||||||
|
|
||||||
@@ -117,22 +115,5 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
return buildParams;
|
return buildParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取构建的耗时(单位:秒)
|
|
||||||
/// </summary>
|
|
||||||
public float GetBuildingSeconds()
|
|
||||||
{
|
|
||||||
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
|
|
||||||
return seconds;
|
|
||||||
}
|
|
||||||
public void BeginWatch()
|
|
||||||
{
|
|
||||||
_buildWatch.Start();
|
|
||||||
}
|
|
||||||
public void StopWatch()
|
|
||||||
{
|
|
||||||
_buildWatch.Stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,6 +48,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] Tags;
|
public string[] Tags;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 引用该资源包的ID列表
|
||||||
|
/// </summary>
|
||||||
|
public int[] ReferenceIDs;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源分类标签的字符串
|
/// 获取资源分类标签的字符串
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public static class BuildLogger
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用LOG
|
||||||
|
/// </summary>
|
||||||
|
public static bool EnableLog = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 日志输出
|
||||||
|
/// </summary>
|
||||||
|
public static void Log(string info)
|
||||||
|
{
|
||||||
|
if (EnableLog)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.Log(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 日志输出
|
||||||
|
/// </summary>
|
||||||
|
public static void Info(string info)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.Log(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2bc82466a51f50141975e4424095aa09
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -2,13 +2,19 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Diagnostics;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuildRunner
|
public class BuildRunner
|
||||||
{
|
{
|
||||||
public static bool EnableLog = true;
|
private static Stopwatch _buildWatch;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 总耗时
|
||||||
|
/// </summary>
|
||||||
|
public static int TotalSeconds = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行构建流程
|
/// 执行构建流程
|
||||||
@@ -23,17 +29,26 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
BuildResult buildResult = new BuildResult();
|
BuildResult buildResult = new BuildResult();
|
||||||
buildResult.Success = true;
|
buildResult.Success = true;
|
||||||
|
TotalSeconds = 0;
|
||||||
for (int i = 0; i < pipeline.Count; i++)
|
for (int i = 0; i < pipeline.Count; i++)
|
||||||
{
|
{
|
||||||
IBuildTask task = pipeline[i];
|
IBuildTask task = pipeline[i];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
_buildWatch = Stopwatch.StartNew();
|
||||||
var taskAttribute = task.GetType().GetCustomAttribute<TaskAttribute>();
|
var taskAttribute = task.GetType().GetCustomAttribute<TaskAttribute>();
|
||||||
Log($"---------------------------------------->{taskAttribute.Desc}<---------------------------------------");
|
BuildLogger.Log($"---------------------------------------->{taskAttribute.Desc}<---------------------------------------");
|
||||||
task.Run(context);
|
task.Run(context);
|
||||||
|
_buildWatch.Stop();
|
||||||
|
|
||||||
|
// 统计耗时
|
||||||
|
int seconds = GetBuildSeconds();
|
||||||
|
TotalSeconds += seconds;
|
||||||
|
BuildLogger.Log($"{taskAttribute.Desc}耗时:{seconds}秒");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
EditorTools.ClearProgressBar();
|
||||||
buildResult.FailedTask = task.GetType().Name;
|
buildResult.FailedTask = task.GetType().Name;
|
||||||
buildResult.FailedInfo = e.ToString();
|
buildResult.FailedInfo = e.ToString();
|
||||||
buildResult.Success = false;
|
buildResult.Success = false;
|
||||||
@@ -42,26 +57,14 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 返回运行结果
|
// 返回运行结果
|
||||||
|
BuildLogger.Log($"构建过程总计耗时:{TotalSeconds}秒");
|
||||||
return buildResult;
|
return buildResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private static int GetBuildSeconds()
|
||||||
/// 日志输出
|
|
||||||
/// </summary>
|
|
||||||
public static void Log(string info)
|
|
||||||
{
|
{
|
||||||
if (EnableLog)
|
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
|
||||||
{
|
return (int)seconds;
|
||||||
UnityEngine.Debug.Log(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 日志输出
|
|
||||||
/// </summary>
|
|
||||||
public static void Info(string info)
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.Log(info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception("构建过程中发生严重错误!请查阅上下文日志!");
|
throw new Exception("构建过程中发生严重错误!请查阅上下文日志!");
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildRunner.Log("Unity引擎打包成功!");
|
BuildLogger.Log("Unity引擎打包成功!");
|
||||||
BuildResultContext buildResultContext = new BuildResultContext();
|
BuildResultContext buildResultContext = new BuildResultContext();
|
||||||
buildResultContext.UnityManifest = buildResults;
|
buildResultContext.UnityManifest = buildResults;
|
||||||
context.SetContextObject(buildResultContext);
|
context.SetContextObject(buildResultContext);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception($"构建过程中发生错误 : {exitCode}");
|
throw new Exception($"构建过程中发生错误 : {exitCode}");
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildRunner.Log("Unity引擎打包成功!");
|
BuildLogger.Log("Unity引擎打包成功!");
|
||||||
BuildResultContext buildResultContext = new BuildResultContext();
|
BuildResultContext buildResultContext = new BuildResultContext();
|
||||||
buildResultContext.Results = buildResults;
|
buildResultContext.Results = buildResults;
|
||||||
context.SetContextObject(buildResultContext);
|
context.SetContextObject(buildResultContext);
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 刷新目录
|
// 刷新目录
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
BuildRunner.Log($"内置文件拷贝完成:{streamingAssetsDirectory}");
|
BuildLogger.Log($"内置文件拷贝完成:{streamingAssetsDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ namespace YooAsset.Editor
|
|||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
var buildResultContext = context.GetContextObject<TaskBuilding.BuildResultContext>();
|
var buildResultContext = context.GetContextObject<TaskBuilding.BuildResultContext>();
|
||||||
UpdateBuiltinPipelineReference(patchManifest, buildResultContext, buildMapContext);
|
UpdateBuiltinPipelineReference(patchManifest, buildResultContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ namespace YooAsset.Editor
|
|||||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
PatchManifestTools.SerializeToJson(filePath, patchManifest);
|
PatchManifestTools.SerializeToJson(filePath, patchManifest);
|
||||||
BuildRunner.Log($"创建补丁清单文件:{filePath}");
|
BuildLogger.Log($"创建补丁清单文件:{filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单二进制文件
|
// 创建补丁清单二进制文件
|
||||||
@@ -86,7 +86,7 @@ namespace YooAsset.Editor
|
|||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
PatchManifestTools.SerializeToBinary(filePath, patchManifest);
|
PatchManifestTools.SerializeToBinary(filePath, patchManifest);
|
||||||
packageHash = HashUtility.FileMD5(filePath);
|
packageHash = HashUtility.FileMD5(filePath);
|
||||||
BuildRunner.Log($"创建补丁清单文件:{filePath}");
|
BuildLogger.Log($"创建补丁清单文件:{filePath}");
|
||||||
|
|
||||||
PatchManifestContext patchManifestContext = new PatchManifestContext();
|
PatchManifestContext patchManifestContext = new PatchManifestContext();
|
||||||
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
||||||
@@ -99,7 +99,7 @@ namespace YooAsset.Editor
|
|||||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
FileUtility.CreateFile(filePath, packageHash);
|
FileUtility.CreateFile(filePath, packageHash);
|
||||||
BuildRunner.Log($"创建补丁清单哈希文件:{filePath}");
|
BuildLogger.Log($"创建补丁清单哈希文件:{filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单版本文件
|
// 创建补丁清单版本文件
|
||||||
@@ -107,7 +107,7 @@ namespace YooAsset.Editor
|
|||||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
FileUtility.CreateFile(filePath, buildParameters.PackageVersion);
|
FileUtility.CreateFile(filePath, buildParameters.PackageVersion);
|
||||||
BuildRunner.Log($"创建补丁清单版本文件:{filePath}");
|
BuildLogger.Log($"创建补丁清单版本文件:{filePath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,30 +231,99 @@ namespace YooAsset.Editor
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
#region 资源包引用关系相关
|
||||||
/// 更新资源包之间的引用关系
|
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
|
||||||
/// </summary>
|
private readonly Dictionary<string, string[]> _cachedBundleDepends = new Dictionary<string, string[]>(10000);
|
||||||
|
|
||||||
private void UpdateScriptPipelineReference(PatchManifest patchManifest, TaskBuilding_SBP.BuildResultContext buildResultContext)
|
private void UpdateScriptPipelineReference(PatchManifest patchManifest, TaskBuilding_SBP.BuildResultContext buildResultContext)
|
||||||
{
|
{
|
||||||
|
int progressValue;
|
||||||
|
int totalCount = patchManifest.BundleList.Count;
|
||||||
|
|
||||||
|
// 缓存资源包ID
|
||||||
|
_cachedBundleID.Clear();
|
||||||
|
progressValue = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
{
|
{
|
||||||
patchBundle.ReferenceIDs = GetScriptPipelineRefrenceIDs(patchManifest, patchBundle, buildResultContext);
|
int bundleID = GetAssetBundleID(patchBundle.BundleName, patchManifest);
|
||||||
}
|
_cachedBundleID.Add(patchBundle.BundleName, bundleID);
|
||||||
}
|
EditorTools.DisplayProgressBar("缓存资源包索引", ++progressValue, totalCount);
|
||||||
private int[] GetScriptPipelineRefrenceIDs(PatchManifest patchManifest, PatchBundle patchBundle, TaskBuilding_SBP.BuildResultContext buildResultContext)
|
|
||||||
{
|
|
||||||
if (buildResultContext.Results.BundleInfos.TryGetValue(patchBundle.BundleName, out var details) == false)
|
|
||||||
{
|
|
||||||
throw new Exception("Should never get here !");
|
|
||||||
}
|
}
|
||||||
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
List<string> referenceList = new List<string>();
|
// 缓存资源包依赖
|
||||||
foreach (var keyValuePair in buildResultContext.Results.BundleInfos)
|
_cachedBundleDepends.Clear();
|
||||||
|
progressValue = 0;
|
||||||
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
{
|
{
|
||||||
string bundleName = keyValuePair.Key;
|
if (patchBundle.IsRawFile)
|
||||||
if (bundleName == patchBundle.BundleName)
|
|
||||||
continue;
|
continue;
|
||||||
if (keyValuePair.Value.Dependencies.Contains(patchBundle.BundleName))
|
|
||||||
|
if (buildResultContext.Results.BundleInfos.ContainsKey(patchBundle.BundleName) == false)
|
||||||
|
throw new Exception($"Not found bundle in SBP build results : {patchBundle.BundleName}");
|
||||||
|
|
||||||
|
var depends = buildResultContext.Results.BundleInfos[patchBundle.BundleName].Dependencies;
|
||||||
|
_cachedBundleDepends.Add(patchBundle.BundleName, depends);
|
||||||
|
EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount);
|
||||||
|
}
|
||||||
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
|
// 计算资源包引用列表
|
||||||
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
|
{
|
||||||
|
patchBundle.ReferenceIDs = GetBundleRefrenceIDs(patchManifest, patchBundle);
|
||||||
|
EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount);
|
||||||
|
}
|
||||||
|
EditorTools.ClearProgressBar();
|
||||||
|
}
|
||||||
|
private void UpdateBuiltinPipelineReference(PatchManifest patchManifest, TaskBuilding.BuildResultContext buildResultContext)
|
||||||
|
{
|
||||||
|
int progressValue;
|
||||||
|
int totalCount = patchManifest.BundleList.Count;
|
||||||
|
|
||||||
|
// 缓存资源包ID
|
||||||
|
_cachedBundleID.Clear();
|
||||||
|
progressValue = 0;
|
||||||
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
|
{
|
||||||
|
int bundleID = GetAssetBundleID(patchBundle.BundleName, patchManifest);
|
||||||
|
_cachedBundleID.Add(patchBundle.BundleName, bundleID);
|
||||||
|
EditorTools.DisplayProgressBar("缓存资源包索引", ++progressValue, totalCount);
|
||||||
|
}
|
||||||
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
|
// 缓存资源包依赖
|
||||||
|
_cachedBundleDepends.Clear();
|
||||||
|
progressValue = 0;
|
||||||
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
|
{
|
||||||
|
var depends = buildResultContext.UnityManifest.GetDirectDependencies(patchBundle.BundleName);
|
||||||
|
_cachedBundleDepends.Add(patchBundle.BundleName, depends);
|
||||||
|
EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount);
|
||||||
|
}
|
||||||
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
|
// 计算资源包引用列表
|
||||||
|
progressValue = 0;
|
||||||
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
|
{
|
||||||
|
patchBundle.ReferenceIDs = GetBundleRefrenceIDs(patchManifest, patchBundle);
|
||||||
|
EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount);
|
||||||
|
}
|
||||||
|
EditorTools.ClearProgressBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] GetBundleRefrenceIDs(PatchManifest patchManifest, PatchBundle targetBundle)
|
||||||
|
{
|
||||||
|
List<string> referenceList = new List<string>();
|
||||||
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
|
{
|
||||||
|
string bundleName = patchBundle.BundleName;
|
||||||
|
if (bundleName == targetBundle.BundleName)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string[] dependencies = GetCachedBundleDepends(bundleName);
|
||||||
|
if (dependencies.Contains(targetBundle.BundleName))
|
||||||
{
|
{
|
||||||
referenceList.Add(bundleName);
|
referenceList.Add(bundleName);
|
||||||
}
|
}
|
||||||
@@ -263,46 +332,28 @@ namespace YooAsset.Editor
|
|||||||
List<int> result = new List<int>();
|
List<int> result = new List<int>();
|
||||||
foreach (var bundleName in referenceList)
|
foreach (var bundleName in referenceList)
|
||||||
{
|
{
|
||||||
int bundleID = GetAssetBundleID(bundleName, patchManifest);
|
int bundleID = GetCachedBundleID(bundleName);
|
||||||
if (result.Contains(bundleID) == false)
|
if (result.Contains(bundleID) == false)
|
||||||
result.Add(bundleID);
|
result.Add(bundleID);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
private int GetCachedBundleID(string bundleName)
|
||||||
/// <summary>
|
|
||||||
/// 更新资源包之间的引用关系
|
|
||||||
/// </summary>
|
|
||||||
private void UpdateBuiltinPipelineReference(PatchManifest patchManifest, TaskBuilding.BuildResultContext buildResultContext, BuildMapContext buildMapContext)
|
|
||||||
{
|
{
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
|
||||||
{
|
{
|
||||||
patchBundle.ReferenceIDs = GetBuiltinPipelineRefrenceIDs(patchManifest, patchBundle, buildResultContext, buildMapContext);
|
throw new Exception($"Not found cached bundle ID : {bundleName}");
|
||||||
}
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
private int[] GetBuiltinPipelineRefrenceIDs(PatchManifest patchManifest, PatchBundle patchBundle, TaskBuilding.BuildResultContext buildResultContext, BuildMapContext buildMapContext)
|
private string[] GetCachedBundleDepends(string bundleName)
|
||||||
{
|
{
|
||||||
List<string> referenceList = new List<string>();
|
if (_cachedBundleDepends.TryGetValue(bundleName, out string[] value) == false)
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
|
||||||
{
|
{
|
||||||
string bundleName = bundleInfo.BundleName;
|
throw new Exception($"Not found cached bundle depends : {bundleName}");
|
||||||
if (bundleName == patchBundle.BundleName)
|
|
||||||
continue;
|
|
||||||
string[] dependencies = buildResultContext.UnityManifest.GetAllDependencies(bundleName);
|
|
||||||
if (dependencies.Contains(patchBundle.BundleName))
|
|
||||||
{
|
|
||||||
referenceList.Add(bundleName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return value;
|
||||||
List<int> result = new List<int>();
|
|
||||||
foreach (var bundleName in referenceList)
|
|
||||||
{
|
|
||||||
int bundleID = GetAssetBundleID(bundleName, patchManifest);
|
|
||||||
if (result.Contains(bundleID) == false)
|
|
||||||
result.Add(bundleID);
|
|
||||||
}
|
|
||||||
return result.ToArray();
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ namespace YooAsset.Editor
|
|||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
BuildRunner.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
|
BuildLogger.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
|
||||||
|
|
||||||
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,16 +13,12 @@ namespace YooAsset.Editor
|
|||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var patchManifestContext = context.GetContextObject<PatchManifestContext>();
|
var patchManifestContext = context.GetContextObject<PatchManifestContext>();
|
||||||
buildParameters.StopWatch();
|
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
if (buildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
CreateReportFile(buildParameters, buildMapContext, patchManifestContext);
|
CreateReportFile(buildParameters, buildMapContext, patchManifestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
float buildSeconds = buildParameters.GetBuildingSeconds();
|
|
||||||
BuildRunner.Info($"Build time consuming {buildSeconds} seconds.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, PatchManifestContext patchManifestContext)
|
private void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, PatchManifestContext patchManifestContext)
|
||||||
@@ -42,7 +38,7 @@ namespace YooAsset.Editor
|
|||||||
#endif
|
#endif
|
||||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||||
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||||
buildReport.Summary.BuildSeconds = (int)buildParametersContext.GetBuildingSeconds();
|
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||||
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
||||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||||
@@ -98,6 +94,7 @@ namespace YooAsset.Editor
|
|||||||
reportBundleInfo.FileCRC = patchBundle.FileCRC;
|
reportBundleInfo.FileCRC = patchBundle.FileCRC;
|
||||||
reportBundleInfo.FileSize = patchBundle.FileSize;
|
reportBundleInfo.FileSize = patchBundle.FileSize;
|
||||||
reportBundleInfo.Tags = patchBundle.Tags;
|
reportBundleInfo.Tags = patchBundle.Tags;
|
||||||
|
reportBundleInfo.ReferenceIDs = patchBundle.ReferenceIDs;
|
||||||
reportBundleInfo.IsRawFile = patchBundle.IsRawFile;
|
reportBundleInfo.IsRawFile = patchBundle.IsRawFile;
|
||||||
reportBundleInfo.LoadMethod = (EBundleLoadMethod)patchBundle.LoadMethod;
|
reportBundleInfo.LoadMethod = (EBundleLoadMethod)patchBundle.LoadMethod;
|
||||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||||
@@ -107,7 +104,7 @@ namespace YooAsset.Editor
|
|||||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
BuildReport.Serialize(filePath, buildReport);
|
BuildReport.Serialize(filePath, buildReport);
|
||||||
BuildRunner.Log($"资源构建报告文件创建完成:{filePath}");
|
BuildLogger.Log($"资源构建报告文件创建完成:{filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -27,17 +27,16 @@ namespace YooAsset.Editor
|
|||||||
private void EncryptingBundleFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void EncryptingBundleFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
var encryptionServices = buildParametersContext.Parameters.EncryptionServices;
|
var encryptionServices = buildParametersContext.Parameters.EncryptionServices;
|
||||||
|
|
||||||
// 如果没有设置加密类
|
|
||||||
if (encryptionServices == null)
|
if (encryptionServices == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (encryptionServices.GetType() == typeof(EncryptionNone))
|
||||||
|
return;
|
||||||
|
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
{
|
{
|
||||||
bundleInfo.LoadMethod = EBundleLoadMethod.Normal;
|
|
||||||
|
|
||||||
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
||||||
fileInfo.BundleName = bundleInfo.BundleName;
|
fileInfo.BundleName = bundleInfo.BundleName;
|
||||||
fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
@@ -56,7 +55,7 @@ namespace YooAsset.Editor
|
|||||||
FileUtility.CreateFile(filePath, encryptResult.EncryptedData);
|
FileUtility.CreateFile(filePath, encryptResult.EncryptedData);
|
||||||
bundleInfo.EncryptedFilePath = filePath;
|
bundleInfo.EncryptedFilePath = filePath;
|
||||||
bundleInfo.LoadMethod = encryptResult.LoadMethod;
|
bundleInfo.LoadMethod = encryptResult.LoadMethod;
|
||||||
BuildRunner.Log($"Bundle文件加密完成:{filePath}");
|
BuildLogger.Log($"Bundle文件加密完成:{filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 进度条
|
// 进度条
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace YooAsset.Editor
|
|||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.PackageName);
|
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.PackageName);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
BuildRunner.Log("构建内容准备完毕!");
|
BuildLogger.Log("构建内容准备完毕!");
|
||||||
|
|
||||||
// 检测构建结果
|
// 检测构建结果
|
||||||
CheckBuildMapContent(buildMapContext);
|
CheckBuildMapContent(buildMapContext);
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
buildParametersContext.BeginWatch();
|
|
||||||
|
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
|
||||||
// 检测构建参数合法性
|
// 检测构建参数合法性
|
||||||
@@ -57,7 +55,7 @@ namespace YooAsset.Editor
|
|||||||
string platformDirectory = $"{buildParameters.OutputRoot}/{buildParameters.PackageName}/{buildParameters.BuildTarget}";
|
string platformDirectory = $"{buildParameters.OutputRoot}/{buildParameters.PackageName}/{buildParameters.BuildTarget}";
|
||||||
if (EditorTools.DeleteDirectory(platformDirectory))
|
if (EditorTools.DeleteDirectory(platformDirectory))
|
||||||
{
|
{
|
||||||
BuildRunner.Log($"删除平台总目录:{platformDirectory}");
|
BuildLogger.Log($"删除平台总目录:{platformDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +63,7 @@ namespace YooAsset.Editor
|
|||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||||
{
|
{
|
||||||
BuildRunner.Log($"创建输出目录:{pipelineOutputDirectory}");
|
BuildLogger.Log($"创建输出目录:{pipelineOutputDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BuildRunner.Log("构建结果验证成功!");
|
BuildLogger.Log("构建结果验证成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace YooAsset.Editor
|
|||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildRunner.Log("构建结果验证成功!");
|
BuildLogger.Log("构建结果验证成功!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class EncryptionNone : IEncryptionServices
|
||||||
|
{
|
||||||
|
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 46b8b200b841799498896403d9d427c2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -794,7 +794,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CollectCommand command = new CollectCommand(EBuildMode.DryRunBuild, _packageNameTxt.value, _enableAddressableToogle.value, _uniqueBundleNameToogle.value);
|
CollectCommand command = new CollectCommand(EBuildMode.SimulateBuild, _packageNameTxt.value, _enableAddressableToogle.value, _uniqueBundleNameToogle.value);
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
@@ -812,12 +812,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
string showInfo = collectAssetInfo.AssetPath;
|
string showInfo = collectAssetInfo.AssetPath;
|
||||||
if (_enableAddressableToogle.value)
|
if (_enableAddressableToogle.value)
|
||||||
{
|
showInfo = $"[{collectAssetInfo.Address}] {collectAssetInfo.AssetPath}";
|
||||||
IAddressRule instance = AssetBundleCollectorSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
|
||||||
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName, collector.UserData);
|
|
||||||
string addressValue = instance.GetAssetAddress(ruleData);
|
|
||||||
showInfo = $"[{addressValue}] {showInfo}";
|
|
||||||
}
|
|
||||||
|
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.text = showInfo;
|
label.text = showInfo;
|
||||||
|
|||||||
@@ -13,5 +13,10 @@ namespace YooAsset.Editor
|
|||||||
/// 收集的包裹名称
|
/// 收集的包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CollectPackage = string.Empty;
|
public string CollectPackage = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 容器值
|
||||||
|
/// </summary>
|
||||||
|
public int ProcessCapacity = 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ namespace YooAsset.Editor
|
|||||||
private TextField _collectOutputField;
|
private TextField _collectOutputField;
|
||||||
private Label _currentShaderCountField;
|
private Label _currentShaderCountField;
|
||||||
private Label _currentVariantCountField;
|
private Label _currentVariantCountField;
|
||||||
|
private SliderInt _processCapacitySlider;
|
||||||
private PopupField<string> _packageField;
|
private PopupField<string> _packageField;
|
||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
@@ -72,6 +73,23 @@ namespace YooAsset.Editor
|
|||||||
packageContainer.Add(_packageField);
|
packageContainer.Add(_packageField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 容器值
|
||||||
|
_processCapacitySlider = root.Q<SliderInt>("ProcessCapacity");
|
||||||
|
_processCapacitySlider.SetValueWithoutNotify(ShaderVariantCollectorSettingData.Setting.ProcessCapacity);
|
||||||
|
#if !UNITY_2020_3_OR_NEWER
|
||||||
|
_processCapacitySlider.label = $"Capacity ({_processCapacitySlider.value})";
|
||||||
|
_processCapacitySlider.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
ShaderVariantCollectorSettingData.Setting.ProcessCapacity = _processCapacitySlider.value;
|
||||||
|
_processCapacitySlider.label = $"Capacity ({_processCapacitySlider.value})";
|
||||||
|
});
|
||||||
|
#else
|
||||||
|
_processCapacitySlider.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
ShaderVariantCollectorSettingData.Setting.ProcessCapacity = _processCapacitySlider.value;
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
_currentShaderCountField = root.Q<Label>("CurrentShaderCount");
|
_currentShaderCountField = root.Q<Label>("CurrentShaderCount");
|
||||||
_currentVariantCountField = root.Q<Label>("CurrentVariantCount");
|
_currentVariantCountField = root.Q<Label>("CurrentVariantCount");
|
||||||
|
|
||||||
@@ -103,7 +121,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
string savePath = ShaderVariantCollectorSettingData.Setting.SavePath;
|
string savePath = ShaderVariantCollectorSettingData.Setting.SavePath;
|
||||||
string packageName = ShaderVariantCollectorSettingData.Setting.CollectPackage;
|
string packageName = ShaderVariantCollectorSettingData.Setting.CollectPackage;
|
||||||
ShaderVariantCollector.Run(savePath, packageName, int.MaxValue, null);
|
int processCapacity = _processCapacitySlider.value;
|
||||||
|
ShaderVariantCollector.Run(savePath, packageName, processCapacity, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建包裹相关
|
// 构建包裹相关
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;" />
|
|
||||||
<ui:VisualElement name="CollectContainer">
|
<ui:VisualElement name="CollectContainer">
|
||||||
<ui:TextField picking-mode="Ignore" label="文件保存路径" name="CollectOutput" style="height: 22px;" />
|
<ui:TextField picking-mode="Ignore" label="文件保存路径" name="CollectOutput" style="height: 22px;" />
|
||||||
<ui:VisualElement name="PackageContainer" style="height: 24px;" />
|
<ui:VisualElement name="PackageContainer" style="height: 24px;">
|
||||||
|
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;" />
|
||||||
|
</ui:VisualElement>
|
||||||
<ui:Label text="Current Shader Count" display-tooltip-when-elided="true" name="CurrentShaderCount" style="height: 20px; padding-left: 4px;" />
|
<ui:Label text="Current Shader Count" display-tooltip-when-elided="true" name="CurrentShaderCount" style="height: 20px; padding-left: 4px;" />
|
||||||
<ui:Label text="Current Variant Count" display-tooltip-when-elided="true" name="CurrentVariantCount" style="height: 20px; padding-left: 4px;" />
|
<ui:Label text="Current Variant Count" display-tooltip-when-elided="true" name="CurrentVariantCount" style="height: 20px; padding-left: 4px;" />
|
||||||
|
<ui:SliderInt picking-mode="Ignore" label="Capacity" value="9999" high-value="1000" name="ProcessCapacity" low-value="10" show-input-field="true" />
|
||||||
<ui:Button text="开始搜集" display-tooltip-when-elided="true" name="CollectButton" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
<ui:Button text="开始搜集" display-tooltip-when-elided="true" name="CollectButton" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -8,11 +8,16 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal class AssetSystemImpl
|
internal class AssetSystemImpl
|
||||||
{
|
{
|
||||||
private readonly List<BundleLoaderBase> _loaders = new List<BundleLoaderBase>(1000);
|
private readonly Dictionary<string, BundleLoaderBase> _loaderDic = new Dictionary<string, BundleLoaderBase>(5000);
|
||||||
private readonly List<ProviderBase> _providers = new List<ProviderBase>(1000);
|
private readonly List<BundleLoaderBase> _loaderList = new List<BundleLoaderBase>(5000);
|
||||||
|
|
||||||
|
private readonly Dictionary<string, ProviderBase> _providerDic = new Dictionary<string, ProviderBase>(5000);
|
||||||
|
private readonly List<ProviderBase> _providerList = new List<ProviderBase>(5000);
|
||||||
|
|
||||||
private readonly static Dictionary<string, SceneOperationHandle> _sceneHandles = new Dictionary<string, SceneOperationHandle>(100);
|
private readonly static Dictionary<string, SceneOperationHandle> _sceneHandles = new Dictionary<string, SceneOperationHandle>(100);
|
||||||
private static long _sceneCreateCount = 0;
|
private static long _sceneCreateCount = 0;
|
||||||
|
|
||||||
|
private bool _isUnloadSafe = true;
|
||||||
private string _packageName;
|
private string _packageName;
|
||||||
private bool _simulationOnEditor;
|
private bool _simulationOnEditor;
|
||||||
private int _loadingMaxNumber;
|
private int _loadingMaxNumber;
|
||||||
@@ -39,7 +44,7 @@ namespace YooAsset
|
|||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
// 更新加载器
|
// 更新加载器
|
||||||
foreach (var loader in _loaders)
|
foreach (var loader in _loaderList)
|
||||||
{
|
{
|
||||||
loader.Update();
|
loader.Update();
|
||||||
}
|
}
|
||||||
@@ -47,10 +52,11 @@ namespace YooAsset
|
|||||||
// 更新资源提供者
|
// 更新资源提供者
|
||||||
// 注意:循环更新的时候,可能会扩展列表
|
// 注意:循环更新的时候,可能会扩展列表
|
||||||
// 注意:不能限制场景对象的加载
|
// 注意:不能限制场景对象的加载
|
||||||
|
_isUnloadSafe = false;
|
||||||
int loadingCount = 0;
|
int loadingCount = 0;
|
||||||
for (int i = 0; i < _providers.Count; i++)
|
for (int i = 0; i < _providerList.Count; i++)
|
||||||
{
|
{
|
||||||
var provider = _providers[i];
|
var provider = _providerList[i];
|
||||||
if (provider.IsSceneProvider())
|
if (provider.IsSceneProvider())
|
||||||
{
|
{
|
||||||
provider.Update();
|
provider.Update();
|
||||||
@@ -64,6 +70,7 @@ namespace YooAsset
|
|||||||
loadingCount++;
|
loadingCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_isUnloadSafe = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -71,17 +78,19 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void DestroyAll()
|
public void DestroyAll()
|
||||||
{
|
{
|
||||||
foreach (var provider in _providers)
|
foreach (var provider in _providerList)
|
||||||
{
|
{
|
||||||
provider.Destroy();
|
provider.Destroy();
|
||||||
}
|
}
|
||||||
_providers.Clear();
|
_providerList.Clear();
|
||||||
|
_providerDic.Clear();
|
||||||
|
|
||||||
foreach (var loader in _loaders)
|
foreach (var loader in _loaderList)
|
||||||
{
|
{
|
||||||
loader.Destroy(true);
|
loader.Destroy(true);
|
||||||
}
|
}
|
||||||
_loaders.Clear();
|
_loaderList.Clear();
|
||||||
|
_loaderDic.Clear();
|
||||||
|
|
||||||
ClearSceneHandle();
|
ClearSceneHandle();
|
||||||
DecryptionServices = null;
|
DecryptionServices = null;
|
||||||
@@ -93,6 +102,12 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void UnloadUnusedAssets()
|
public void UnloadUnusedAssets()
|
||||||
{
|
{
|
||||||
|
if (_isUnloadSafe == false)
|
||||||
|
{
|
||||||
|
YooLogger.Warning("Can not unload unused assets when processing resource loading !");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 注意:资源包之间可能存在多层深层嵌套,需要多次循环释放。
|
// 注意:资源包之间可能存在多层深层嵌套,需要多次循环释放。
|
||||||
int loopCount = 10;
|
int loopCount = 10;
|
||||||
for (int i = 0; i < loopCount; i++)
|
for (int i = 0; i < loopCount; i++)
|
||||||
@@ -104,29 +119,33 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_simulationOnEditor)
|
if (_simulationOnEditor)
|
||||||
{
|
{
|
||||||
for (int i = _providers.Count - 1; i >= 0; i--)
|
for (int i = _providerList.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (_providers[i].CanDestroy())
|
var provider = _providerList[i];
|
||||||
|
if (provider.CanDestroy())
|
||||||
{
|
{
|
||||||
_providers[i].Destroy();
|
provider.Destroy();
|
||||||
_providers.RemoveAt(i);
|
_providerList.RemoveAt(i);
|
||||||
|
_providerDic.Remove(provider.ProviderGUID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = _loaders.Count - 1; i >= 0; i--)
|
for (int i = _loaderList.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
BundleLoaderBase loader = _loaders[i];
|
BundleLoaderBase loader = _loaderList[i];
|
||||||
loader.TryDestroyAllProviders();
|
loader.TryDestroyAllProviders();
|
||||||
}
|
}
|
||||||
for (int i = _loaders.Count - 1; i >= 0; i--)
|
for (int i = _loaderList.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
BundleLoaderBase loader = _loaders[i];
|
BundleLoaderBase loader = _loaderList[i];
|
||||||
if (loader.CanDestroy())
|
if (loader.CanDestroy())
|
||||||
{
|
{
|
||||||
|
string bundleName = loader.MainBundleInfo.Bundle.BundleName;
|
||||||
loader.Destroy(false);
|
loader.Destroy(false);
|
||||||
_loaders.RemoveAt(i);
|
_loaderList.RemoveAt(i);
|
||||||
|
_loaderDic.Remove(bundleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,17 +156,19 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ForceUnloadAllAssets()
|
public void ForceUnloadAllAssets()
|
||||||
{
|
{
|
||||||
foreach (var provider in _providers)
|
foreach (var provider in _providerList)
|
||||||
{
|
{
|
||||||
provider.Destroy();
|
provider.Destroy();
|
||||||
}
|
}
|
||||||
foreach (var loader in _loaders)
|
foreach (var loader in _loaderList)
|
||||||
{
|
{
|
||||||
loader.Destroy(true);
|
loader.Destroy(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_providers.Clear();
|
_providerList.Clear();
|
||||||
_loaders.Clear();
|
_providerDic.Clear();
|
||||||
|
_loaderList.Clear();
|
||||||
|
_loaderDic.Clear();
|
||||||
ClearSceneHandle();
|
ClearSceneHandle();
|
||||||
|
|
||||||
// 注意:调用底层接口释放所有资源
|
// 注意:调用底层接口释放所有资源
|
||||||
@@ -182,7 +203,8 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, activateOnLoad, priority);
|
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, activateOnLoad, priority);
|
||||||
provider.InitSpawnDebugInfo();
|
provider.InitSpawnDebugInfo();
|
||||||
_providers.Add(provider);
|
_providerList.Add(provider);
|
||||||
|
_providerDic.Add(providerGUID, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
var handle = provider.CreateHandle<SceneOperationHandle>();
|
var handle = provider.CreateHandle<SceneOperationHandle>();
|
||||||
@@ -213,7 +235,8 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
provider = new BundledAssetProvider(this, providerGUID, assetInfo);
|
provider = new BundledAssetProvider(this, providerGUID, assetInfo);
|
||||||
provider.InitSpawnDebugInfo();
|
provider.InitSpawnDebugInfo();
|
||||||
_providers.Add(provider);
|
_providerList.Add(provider);
|
||||||
|
_providerDic.Add(providerGUID, provider);
|
||||||
}
|
}
|
||||||
return provider.CreateHandle<AssetOperationHandle>();
|
return provider.CreateHandle<AssetOperationHandle>();
|
||||||
}
|
}
|
||||||
@@ -240,7 +263,8 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
provider = new BundledSubAssetsProvider(this, providerGUID, assetInfo);
|
provider = new BundledSubAssetsProvider(this, providerGUID, assetInfo);
|
||||||
provider.InitSpawnDebugInfo();
|
provider.InitSpawnDebugInfo();
|
||||||
_providers.Add(provider);
|
_providerList.Add(provider);
|
||||||
|
_providerDic.Add(providerGUID, provider);
|
||||||
}
|
}
|
||||||
return provider.CreateHandle<SubAssetsOperationHandle>();
|
return provider.CreateHandle<SubAssetsOperationHandle>();
|
||||||
}
|
}
|
||||||
@@ -267,7 +291,8 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
provider = new BundledRawFileProvider(this, providerGUID, assetInfo);
|
provider = new BundledRawFileProvider(this, providerGUID, assetInfo);
|
||||||
provider.InitSpawnDebugInfo();
|
provider.InitSpawnDebugInfo();
|
||||||
_providers.Add(provider);
|
_providerList.Add(provider);
|
||||||
|
_providerDic.Add(providerGUID, provider);
|
||||||
}
|
}
|
||||||
return provider.CreateHandle<RawFileOperationHandle>();
|
return provider.CreateHandle<RawFileOperationHandle>();
|
||||||
}
|
}
|
||||||
@@ -338,22 +363,24 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
foreach (var provider in providers)
|
foreach (var provider in providers)
|
||||||
{
|
{
|
||||||
_providers.Remove(provider);
|
_providerList.Remove(provider);
|
||||||
|
_providerDic.Remove(provider.ProviderGUID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal bool CheckBundleCanDestroy(int bundleID)
|
internal bool CheckBundleDestroyed(int bundleID)
|
||||||
{
|
{
|
||||||
string bundleName = BundleServices.GetBundleName(bundleID);
|
string bundleName = BundleServices.GetBundleName(bundleID);
|
||||||
BundleLoaderBase loader = TryGetAssetBundleLoader(bundleName);
|
BundleLoaderBase loader = TryGetAssetBundleLoader(bundleName);
|
||||||
if (loader == null)
|
if (loader == null)
|
||||||
return true;
|
return true;
|
||||||
return loader.CanDestroy();
|
return loader.IsDestroyed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
|
private BundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
// 如果加载器已经存在
|
// 如果加载器已经存在
|
||||||
BundleLoaderBase loader = TryGetAssetBundleLoader(bundleInfo.Bundle.BundleName);
|
string bundleName = bundleInfo.Bundle.BundleName;
|
||||||
|
BundleLoaderBase loader = TryGetAssetBundleLoader(bundleName);
|
||||||
if (loader != null)
|
if (loader != null)
|
||||||
return loader;
|
return loader;
|
||||||
|
|
||||||
@@ -370,43 +397,30 @@ namespace YooAsset
|
|||||||
loader = new AssetBundleFileLoader(this, bundleInfo);
|
loader = new AssetBundleFileLoader(this, bundleInfo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_loaders.Add(loader);
|
_loaderList.Add(loader);
|
||||||
|
_loaderDic.Add(bundleName, loader);
|
||||||
return loader;
|
return loader;
|
||||||
}
|
}
|
||||||
private BundleLoaderBase TryGetAssetBundleLoader(string bundleName)
|
private BundleLoaderBase TryGetAssetBundleLoader(string bundleName)
|
||||||
{
|
{
|
||||||
BundleLoaderBase loader = null;
|
if (_loaderDic.TryGetValue(bundleName, out BundleLoaderBase value))
|
||||||
for (int i = 0; i < _loaders.Count; i++)
|
return value;
|
||||||
{
|
else
|
||||||
BundleLoaderBase temp = _loaders[i];
|
return null;
|
||||||
if (temp.MainBundleInfo.Bundle.BundleName.Equals(bundleName))
|
|
||||||
{
|
|
||||||
loader = temp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return loader;
|
|
||||||
}
|
}
|
||||||
private ProviderBase TryGetProvider(string providerGUID)
|
private ProviderBase TryGetProvider(string providerGUID)
|
||||||
{
|
{
|
||||||
ProviderBase provider = null;
|
if (_providerDic.TryGetValue(providerGUID, out ProviderBase value))
|
||||||
for (int i = 0; i < _providers.Count; i++)
|
return value;
|
||||||
{
|
else
|
||||||
ProviderBase temp = _providers[i];
|
return null;
|
||||||
if (temp.ProviderGUID.Equals(providerGUID))
|
|
||||||
{
|
|
||||||
provider = temp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return provider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 调试信息
|
#region 调试信息
|
||||||
internal List<DebugProviderInfo> GetDebugReportInfos()
|
internal List<DebugProviderInfo> GetDebugReportInfos()
|
||||||
{
|
{
|
||||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providers.Count);
|
List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providerList.Count);
|
||||||
foreach (var provider in _providers)
|
foreach (var provider in _providerList)
|
||||||
{
|
{
|
||||||
DebugProviderInfo providerInfo = new DebugProviderInfo();
|
DebugProviderInfo providerInfo = new DebugProviderInfo();
|
||||||
providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;
|
providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;
|
||||||
@@ -429,9 +443,9 @@ namespace YooAsset
|
|||||||
internal List<BundleInfo> GetLoadedBundleInfos()
|
internal List<BundleInfo> GetLoadedBundleInfos()
|
||||||
{
|
{
|
||||||
List<BundleInfo> result = new List<BundleInfo>(100);
|
List<BundleInfo> result = new List<BundleInfo>(100);
|
||||||
foreach (var bundleLoader in _loaders)
|
foreach (var loader in _loaderList)
|
||||||
{
|
{
|
||||||
result.Add(bundleLoader.MainBundleInfo);
|
result.Add(loader.MainBundleInfo);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,18 @@ namespace YooAsset
|
|||||||
if (IsDone() == false)
|
if (IsDone() == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return RefCount <= 0;
|
if (RefCount > 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 检查引用链上的资源包是否已经全部销毁
|
||||||
|
// 注意:互相引用的资源包无法卸载!
|
||||||
|
foreach (var bundleID in MainBundleInfo.Bundle.ReferenceIDs)
|
||||||
|
{
|
||||||
|
if (Impl.CheckBundleDestroyed(bundleID) == false)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -122,24 +133,15 @@ namespace YooAsset
|
|||||||
if (RefCount > _providers.Count)
|
if (RefCount > _providers.Count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 条件3:检查依赖链上的资源包
|
|
||||||
// 依赖该资源包的所有资源包可以销毁
|
|
||||||
// 注意:互相引用的资源包无法卸载!
|
|
||||||
foreach (var bundleID in MainBundleInfo.Bundle.ReferenceIDs)
|
|
||||||
{
|
|
||||||
if (Impl.CheckBundleCanDestroy(bundleID) == false)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 销毁所有Providers
|
// 销毁所有Providers
|
||||||
foreach (var provider in _providers)
|
|
||||||
{
|
{
|
||||||
provider.Destroy();
|
foreach (var provider in _providers)
|
||||||
|
{
|
||||||
|
provider.Destroy();
|
||||||
|
}
|
||||||
|
Impl.RemoveBundleProviders(_providers);
|
||||||
|
_providers.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从列表里移除Providers
|
|
||||||
Impl.RemoveBundleProviders(_providers);
|
|
||||||
_providers.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
DebugRecording();
|
DebugBeginRecording();
|
||||||
|
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
DebugRecording();
|
DebugBeginRecording();
|
||||||
|
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
DebugRecording();
|
DebugBeginRecording();
|
||||||
|
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
DebugRecording();
|
DebugBeginRecording();
|
||||||
|
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -221,6 +221,8 @@ namespace YooAsset
|
|||||||
private TaskCompletionSource<object> _taskCompletionSource;
|
private TaskCompletionSource<object> _taskCompletionSource;
|
||||||
protected void InvokeCompletion()
|
protected void InvokeCompletion()
|
||||||
{
|
{
|
||||||
|
DebugEndRecording();
|
||||||
|
|
||||||
// 进度百分百完成
|
// 进度百分百完成
|
||||||
Progress = 1f;
|
Progress = 1f;
|
||||||
|
|
||||||
@@ -256,8 +258,7 @@ namespace YooAsset
|
|||||||
public long LoadingTime { protected set; get; }
|
public long LoadingTime { protected set; get; }
|
||||||
|
|
||||||
// 加载耗时统计
|
// 加载耗时统计
|
||||||
private bool _isRecording = false;
|
private Stopwatch _watch = null;
|
||||||
private Stopwatch _watch;
|
|
||||||
|
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
public void InitSpawnDebugInfo()
|
public void InitSpawnDebugInfo()
|
||||||
@@ -274,21 +275,21 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
protected void DebugRecording()
|
protected void DebugBeginRecording()
|
||||||
{
|
{
|
||||||
if (_isRecording == false)
|
if (_watch == null)
|
||||||
{
|
{
|
||||||
_isRecording = true;
|
|
||||||
_watch = Stopwatch.StartNew();
|
_watch = Stopwatch.StartNew();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Conditional("DEBUG")]
|
||||||
|
private void DebugEndRecording()
|
||||||
|
{
|
||||||
if (_watch != null)
|
if (_watch != null)
|
||||||
{
|
{
|
||||||
if (IsDone)
|
LoadingTime = _watch.ElapsedMilliseconds;
|
||||||
{
|
_watch = null;
|
||||||
LoadingTime = _watch.ElapsedMilliseconds;
|
|
||||||
_watch = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -23,6 +23,15 @@ namespace YooAsset
|
|||||||
_cachedDic.Clear();
|
_cachedDic.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存文件总数
|
||||||
|
/// </summary>
|
||||||
|
public static int GetCachedFilesCount(string packageName)
|
||||||
|
{
|
||||||
|
var cache = GetOrCreateCache(packageName);
|
||||||
|
return cache.GetCachedFilesCount();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询是否为验证文件
|
/// 查询是否为验证文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -70,7 +79,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证缓存文件(子线程内操作)
|
/// 验证缓存文件(子线程内操作)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static EVerifyResult VerifyingCacheFile(VerifyElement element)
|
public static EVerifyResult VerifyingCacheFile(VerifyCacheElement element)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -100,15 +109,15 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证下载文件
|
/// 验证下载文件(子线程内操作)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static EVerifyResult VerifyingTempFile(PatchBundle patchBundle)
|
public static EVerifyResult VerifyingTempFile(VerifyTempElement element)
|
||||||
{
|
{
|
||||||
return VerifyingInternal(patchBundle.TempDataFilePath, patchBundle.FileSize, patchBundle.FileCRC, EVerifyLevel.High);
|
return VerifyingInternal(element.TempDataFilePath, element.FileSize, element.FileCRC, EVerifyLevel.High);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证记录文件
|
/// 验证记录文件(主线程内操作)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static EVerifyResult VerifyingRecordFile(string packageName, string cacheGUID)
|
public static EVerifyResult VerifyingRecordFile(string packageName, string cacheGUID)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a93a516506b2b5c4492fdefe26eb1175
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class FindCacheFilesOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
FindPrepare,
|
||||||
|
FindBundleFiles,
|
||||||
|
FindRawFiles,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly string _packageName;
|
||||||
|
private float _verifyStartTime;
|
||||||
|
private IEnumerator<DirectoryInfo> _bundleFilesEnumerator = null;
|
||||||
|
private IEnumerator<DirectoryInfo> _rawFilesEnumerator = null;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 需要验证的元素
|
||||||
|
/// </summary>
|
||||||
|
public readonly List<VerifyCacheElement> VerifyElements = new List<VerifyCacheElement>(5000);
|
||||||
|
|
||||||
|
public FindCacheFilesOperation(string packageName)
|
||||||
|
{
|
||||||
|
_packageName = packageName;
|
||||||
|
}
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
_steps = ESteps.FindPrepare;
|
||||||
|
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.FindPrepare)
|
||||||
|
{
|
||||||
|
// BundleFiles
|
||||||
|
{
|
||||||
|
string rootPath = PersistentHelper.GetCachedBundleFileFolderPath(_packageName);
|
||||||
|
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
||||||
|
if (rootDirectory.Exists)
|
||||||
|
{
|
||||||
|
var directorieInfos = rootDirectory.EnumerateDirectories();
|
||||||
|
_bundleFilesEnumerator = directorieInfos.GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RawFiles
|
||||||
|
{
|
||||||
|
string rootPath = PersistentHelper.GetCachedRawFileFolderPath(_packageName);
|
||||||
|
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
||||||
|
if (rootDirectory.Exists)
|
||||||
|
{
|
||||||
|
var directorieInfos = rootDirectory.EnumerateDirectories();
|
||||||
|
_rawFilesEnumerator = directorieInfos.GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_steps = ESteps.FindBundleFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.FindBundleFiles)
|
||||||
|
{
|
||||||
|
if (UpdateFindBundleFiles())
|
||||||
|
return;
|
||||||
|
|
||||||
|
_steps = ESteps.FindRawFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.FindRawFiles)
|
||||||
|
{
|
||||||
|
if (UpdateFindRawFiles())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 注意:总是返回成功
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyStartTime;
|
||||||
|
YooLogger.Log($"Find cache files elapsed time {costTime:f1} seconds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool UpdateFindBundleFiles()
|
||||||
|
{
|
||||||
|
if (_bundleFilesEnumerator == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool isFindItem;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
isFindItem = _bundleFilesEnumerator.MoveNext();
|
||||||
|
if (isFindItem == false)
|
||||||
|
break;
|
||||||
|
|
||||||
|
var rootFoder = _bundleFilesEnumerator.Current;
|
||||||
|
var childDirectories = rootFoder.GetDirectories();
|
||||||
|
foreach(var chidDirectory in childDirectories)
|
||||||
|
{
|
||||||
|
string cacheGUID = chidDirectory.Name;
|
||||||
|
if (CacheSystem.IsCached(_packageName, cacheGUID))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 创建验证元素类
|
||||||
|
string fileRootPath = chidDirectory.FullName;
|
||||||
|
string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}";
|
||||||
|
string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}";
|
||||||
|
VerifyCacheElement element = new VerifyCacheElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
|
||||||
|
VerifyElements.Add(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OperationSystem.IsBusy)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isFindItem;
|
||||||
|
}
|
||||||
|
private bool UpdateFindRawFiles()
|
||||||
|
{
|
||||||
|
if (_rawFilesEnumerator == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool isFindItem;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
isFindItem = _rawFilesEnumerator.MoveNext();
|
||||||
|
if (isFindItem == false)
|
||||||
|
break;
|
||||||
|
|
||||||
|
var rootFoder = _rawFilesEnumerator.Current;
|
||||||
|
var childDirectories = rootFoder.GetDirectories();
|
||||||
|
foreach (var chidDirectory in childDirectories)
|
||||||
|
{
|
||||||
|
string cacheGUID = chidDirectory.Name;
|
||||||
|
if (CacheSystem.IsCached(_packageName, cacheGUID))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 获取数据文件的后缀名
|
||||||
|
string dataFileExtension = string.Empty;
|
||||||
|
var fileInfos = chidDirectory.GetFiles();
|
||||||
|
foreach (var fileInfo in fileInfos)
|
||||||
|
{
|
||||||
|
if (fileInfo.Extension == ".temp")
|
||||||
|
continue;
|
||||||
|
if (fileInfo.Name.StartsWith(YooAssetSettings.CacheBundleDataFileName))
|
||||||
|
{
|
||||||
|
dataFileExtension = fileInfo.Extension;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建验证元素类
|
||||||
|
string fileRootPath = chidDirectory.FullName;
|
||||||
|
string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}{dataFileExtension}";
|
||||||
|
string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}";
|
||||||
|
VerifyCacheElement element = new VerifyCacheElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
|
||||||
|
VerifyElements.Add(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OperationSystem.IsBusy)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isFindItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 00ec004354d75ac499606d6959192f9b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -6,14 +6,14 @@ using System.Threading;
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal abstract class PackageVerifyOperation : AsyncOperationBase
|
internal abstract class VerifyCacheFilesOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
public static PackageVerifyOperation CreateOperation(List<VerifyElement> elements)
|
public static VerifyCacheFilesOperation CreateOperation(List<VerifyCacheElement> elements)
|
||||||
{
|
{
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
var operation = new PackageVerifyWithoutThreadOperation(elements);
|
var operation = new VerifyCacheFilesWithoutThreadOperation(elements);
|
||||||
#else
|
#else
|
||||||
var operation = new PackageVerifyWithThreadOperation(elements);
|
var operation = new VerifyCacheFilesWithThreadOperation(elements);
|
||||||
#endif
|
#endif
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 本地缓存文件验证(线程版)
|
/// 本地缓存文件验证(线程版)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class PackageVerifyWithThreadOperation : PackageVerifyOperation
|
internal class VerifyCacheFilesWithThreadOperation : VerifyCacheFilesOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
@@ -33,8 +33,8 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
||||||
private List<VerifyElement> _waitingList;
|
private List<VerifyCacheElement> _waitingList;
|
||||||
private List<VerifyElement> _verifyingList;
|
private List<VerifyCacheElement> _verifyingList;
|
||||||
private int _verifyMaxNum;
|
private int _verifyMaxNum;
|
||||||
private int _verifyTotalCount;
|
private int _verifyTotalCount;
|
||||||
private float _verifyStartTime;
|
private float _verifyStartTime;
|
||||||
@@ -42,7 +42,7 @@ namespace YooAsset
|
|||||||
private int _failedCount;
|
private int _failedCount;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
public PackageVerifyWithThreadOperation(List<VerifyElement> elements)
|
public VerifyCacheFilesWithThreadOperation(List<VerifyCacheElement> elements)
|
||||||
{
|
{
|
||||||
_waitingList = elements;
|
_waitingList = elements;
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ namespace YooAsset
|
|||||||
if (_verifyMaxNum < 1)
|
if (_verifyMaxNum < 1)
|
||||||
_verifyMaxNum = 1;
|
_verifyMaxNum = 1;
|
||||||
|
|
||||||
_verifyingList = new List<VerifyElement>(_verifyMaxNum);
|
_verifyingList = new List<VerifyCacheElement>(_verifyMaxNum);
|
||||||
_steps = ESteps.UpdateVerify;
|
_steps = ESteps.UpdateVerify;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyStartTime;
|
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyStartTime;
|
||||||
YooLogger.Log($"Package verify elapsed time {costTime:f1} seconds");
|
YooLogger.Log($"Verify cache files elapsed time {costTime:f1} seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = _waitingList.Count - 1; i >= 0; i--)
|
for (int i = _waitingList.Count - 1; i >= 0; i--)
|
||||||
@@ -114,19 +114,19 @@ namespace YooAsset
|
|||||||
return 1f;
|
return 1f;
|
||||||
return (float)(_succeedCount + _failedCount) / _verifyTotalCount;
|
return (float)(_succeedCount + _failedCount) / _verifyTotalCount;
|
||||||
}
|
}
|
||||||
private bool BeginVerifyFileWithThread(VerifyElement element)
|
private bool BeginVerifyFileWithThread(VerifyCacheElement element)
|
||||||
{
|
{
|
||||||
return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), element);
|
return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), element);
|
||||||
}
|
}
|
||||||
private void VerifyInThread(object obj)
|
private void VerifyInThread(object obj)
|
||||||
{
|
{
|
||||||
VerifyElement element = (VerifyElement)obj;
|
VerifyCacheElement element = (VerifyCacheElement)obj;
|
||||||
element.Result = CacheSystem.VerifyingCacheFile(element);
|
element.Result = CacheSystem.VerifyingCacheFile(element);
|
||||||
_syncContext.Post(VerifyCallback, element);
|
_syncContext.Post(VerifyCallback, element);
|
||||||
}
|
}
|
||||||
private void VerifyCallback(object obj)
|
private void VerifyCallback(object obj)
|
||||||
{
|
{
|
||||||
VerifyElement element = (VerifyElement)obj;
|
VerifyCacheElement element = (VerifyCacheElement)obj;
|
||||||
_verifyingList.Remove(element);
|
_verifyingList.Remove(element);
|
||||||
|
|
||||||
if (element.Result == EVerifyResult.Succeed)
|
if (element.Result == EVerifyResult.Succeed)
|
||||||
@@ -148,7 +148,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 本地缓存文件验证(非线程版)
|
/// 本地缓存文件验证(非线程版)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class PackageVerifyWithoutThreadOperation : PackageVerifyOperation
|
internal class VerifyCacheFilesWithoutThreadOperation : VerifyCacheFilesOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
@@ -158,16 +158,16 @@ namespace YooAsset
|
|||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<VerifyElement> _waitingList;
|
private List<VerifyCacheElement> _waitingList;
|
||||||
private List<VerifyElement> _verifyingList;
|
private List<VerifyCacheElement> _verifyingList;
|
||||||
private int _verifyMaxNum;
|
private int _verifyMaxNum;
|
||||||
private int _verifyTotalCount;
|
private int _verifyTotalCount;
|
||||||
private float _verifyStartTime;
|
private float _verifyStartTime;
|
||||||
private int _succeedCount;
|
private int _succeedCount;
|
||||||
private int _failedCount;
|
private int _failedCount;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
public PackageVerifyWithoutThreadOperation(List<VerifyElement> elements)
|
public VerifyCacheFilesWithoutThreadOperation(List<VerifyCacheElement> elements)
|
||||||
{
|
{
|
||||||
_waitingList = elements;
|
_waitingList = elements;
|
||||||
}
|
}
|
||||||
@@ -189,7 +189,7 @@ namespace YooAsset
|
|||||||
_verifyMaxNum = fileCount;
|
_verifyMaxNum = fileCount;
|
||||||
_verifyTotalCount = fileCount;
|
_verifyTotalCount = fileCount;
|
||||||
|
|
||||||
_verifyingList = new List<VerifyElement>(_verifyMaxNum);
|
_verifyingList = new List<VerifyCacheElement>(_verifyMaxNum);
|
||||||
_steps = ESteps.UpdateVerify;
|
_steps = ESteps.UpdateVerify;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ namespace YooAsset
|
|||||||
return 1f;
|
return 1f;
|
||||||
return (float)(_succeedCount + _failedCount) / _verifyTotalCount;
|
return (float)(_succeedCount + _failedCount) / _verifyTotalCount;
|
||||||
}
|
}
|
||||||
private void BeginVerifyFileWithoutThread(VerifyElement element)
|
private void BeginVerifyFileWithoutThread(VerifyCacheElement element)
|
||||||
{
|
{
|
||||||
element.Result = CacheSystem.VerifyingCacheFile(element);
|
element.Result = CacheSystem.VerifyingCacheFile(element);
|
||||||
if (element.Result == EVerifyResult.Succeed)
|
if (element.Result == EVerifyResult.Succeed)
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal abstract class VerifyTempFileOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
public EVerifyResult VerifyResult { protected set; get; }
|
||||||
|
|
||||||
|
public static VerifyTempFileOperation CreateOperation(VerifyTempElement element)
|
||||||
|
{
|
||||||
|
#if UNITY_WEBGL
|
||||||
|
var operation = new VerifyTempFileWithoutThreadOperation(element);
|
||||||
|
#else
|
||||||
|
var operation = new VerifyTempFileWithThreadOperation(element);
|
||||||
|
#endif
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载文件验证(线程版)
|
||||||
|
/// </summary>
|
||||||
|
internal class VerifyTempFileWithThreadOperation : VerifyTempFileOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
VerifyFile,
|
||||||
|
Waiting,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly VerifyTempElement _element;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
public VerifyTempFileWithThreadOperation(VerifyTempElement element)
|
||||||
|
{
|
||||||
|
_element = element;
|
||||||
|
}
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
_steps = ESteps.VerifyFile;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.VerifyFile)
|
||||||
|
{
|
||||||
|
if (BeginVerifyFileWithThread(_element))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Waiting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool BeginVerifyFileWithThread(VerifyTempElement element)
|
||||||
|
{
|
||||||
|
return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), element);
|
||||||
|
}
|
||||||
|
private void VerifyInThread(object obj)
|
||||||
|
{
|
||||||
|
VerifyTempElement element = (VerifyTempElement)obj;
|
||||||
|
element.Result = CacheSystem.VerifyingTempFile(element);
|
||||||
|
DownloadSystem.SyncContext.Post(VerifyCallback, element);
|
||||||
|
}
|
||||||
|
private void VerifyCallback(object obj)
|
||||||
|
{
|
||||||
|
VerifyTempElement element = (VerifyTempElement)obj;
|
||||||
|
VerifyResult = element.Result;
|
||||||
|
if (element.Result == EVerifyResult.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Failed verify file : {element.TempDataFilePath} ! ErrorCode : {element.Result}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载文件验证(非线程版)
|
||||||
|
/// </summary>
|
||||||
|
internal class VerifyTempFileWithoutThreadOperation : VerifyTempFileOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
VerifyFile,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly VerifyTempElement _element;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
public VerifyTempFileWithoutThreadOperation(VerifyTempElement element)
|
||||||
|
{
|
||||||
|
_element = element;
|
||||||
|
}
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
_steps = ESteps.VerifyFile;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.VerifyFile)
|
||||||
|
{
|
||||||
|
_element.Result = CacheSystem.VerifyingTempFile(_element);
|
||||||
|
VerifyResult = _element.Result;
|
||||||
|
if (_element.Result == EVerifyResult.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Failed verify file : {_element.TempDataFilePath} ! ErrorCode : {_element.Result}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cd356e68c5b4ef04ab018a6388f5173a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -10,13 +10,14 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
GetCacheFiles,
|
FindCacheFiles,
|
||||||
VerifyCacheFiles,
|
VerifyCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly string _packageName;
|
private readonly string _packageName;
|
||||||
private PackageVerifyOperation _packageVerifyOp;
|
private FindCacheFilesOperation _findCacheFilesOp;
|
||||||
|
private VerifyCacheFilesOperation _verifyCacheFilesOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
public PackageCachingOperation(string packageName)
|
public PackageCachingOperation(string packageName)
|
||||||
@@ -25,71 +26,47 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
_steps = ESteps.GetCacheFiles;
|
_steps = ESteps.FindCacheFiles;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.GetCacheFiles)
|
if (_steps == ESteps.FindCacheFiles)
|
||||||
{
|
{
|
||||||
var elements = GetVerifyElements();
|
if (_findCacheFilesOp == null)
|
||||||
_packageVerifyOp = PackageVerifyOperation.CreateOperation(elements);
|
{
|
||||||
OperationSystem.StartOperation(_packageVerifyOp);
|
_findCacheFilesOp = new FindCacheFilesOperation(_packageName);
|
||||||
|
OperationSystem.StartOperation(_findCacheFilesOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
Progress = _findCacheFilesOp.Progress;
|
||||||
|
if (_findCacheFilesOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
_steps = ESteps.VerifyCacheFiles;
|
_steps = ESteps.VerifyCacheFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.VerifyCacheFiles)
|
if (_steps == ESteps.VerifyCacheFiles)
|
||||||
{
|
{
|
||||||
Progress = _packageVerifyOp.Progress;
|
if (_verifyCacheFilesOp == null)
|
||||||
if (_packageVerifyOp.IsDone == false)
|
{
|
||||||
|
_verifyCacheFilesOp = VerifyCacheFilesOperation.CreateOperation(_findCacheFilesOp.VerifyElements);
|
||||||
|
OperationSystem.StartOperation(_verifyCacheFilesOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
Progress = _verifyCacheFilesOp.Progress;
|
||||||
|
if (_verifyCacheFilesOp.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 注意:总是返回成功
|
// 注意:总是返回成功
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
|
|
||||||
|
int totalCount = CacheSystem.GetCachedFilesCount(_packageName);
|
||||||
|
YooLogger.Log($"Package '{_packageName}' cached files count : {totalCount}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<VerifyElement> GetVerifyElements()
|
|
||||||
{
|
|
||||||
string cacheFolderPath = PersistentHelper.GetCacheFolderPath(_packageName);
|
|
||||||
if (Directory.Exists(cacheFolderPath) == false)
|
|
||||||
return new List<VerifyElement>();
|
|
||||||
|
|
||||||
DirectoryInfo rootDirectory = new DirectoryInfo(cacheFolderPath);
|
|
||||||
DirectoryInfo[] fileFolders = rootDirectory.GetDirectories();
|
|
||||||
List<VerifyElement> result = new List<VerifyElement>(fileFolders.Length);
|
|
||||||
foreach (var fileFoder in fileFolders)
|
|
||||||
{
|
|
||||||
string cacheGUID = fileFoder.Name;
|
|
||||||
if (CacheSystem.IsCached(_packageName, cacheGUID))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// 获取数据文件的后缀名
|
|
||||||
string dataFileExtension = string.Empty;
|
|
||||||
var fileInfos = fileFoder.GetFiles();
|
|
||||||
foreach (var fileInfo in fileInfos)
|
|
||||||
{
|
|
||||||
if (fileInfo.Extension == ".temp")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (fileInfo.Name.StartsWith(YooAssetSettings.CacheBundleDataFileName))
|
|
||||||
{
|
|
||||||
dataFileExtension = fileInfo.Extension;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string fileRootPath = fileFoder.FullName;
|
|
||||||
string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}{dataFileExtension}";
|
|
||||||
string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}";
|
|
||||||
VerifyElement element = new VerifyElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
|
|
||||||
result.Add(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,6 +44,14 @@ namespace YooAsset
|
|||||||
_wrappers.Clear();
|
_wrappers.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存文件总数
|
||||||
|
/// </summary>
|
||||||
|
public int GetCachedFilesCount()
|
||||||
|
{
|
||||||
|
return _wrappers.Count;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询缓存记录
|
/// 查询缓存记录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -2,19 +2,22 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class VerifyElement
|
/// <summary>
|
||||||
|
/// 缓存文件验证元素
|
||||||
|
/// </summary>
|
||||||
|
internal class VerifyCacheElement
|
||||||
{
|
{
|
||||||
public string PackageName { private set; get; }
|
public string PackageName { private set; get; }
|
||||||
public string CacheGUID { private set; get; }
|
public string CacheGUID { private set; get; }
|
||||||
public string FileRootPath { private set; get; }
|
public string FileRootPath { private set; get; }
|
||||||
public string DataFilePath { private set; get; }
|
public string DataFilePath { private set; get; }
|
||||||
public string InfoFilePath { private set; get; }
|
public string InfoFilePath { private set; get; }
|
||||||
|
|
||||||
public EVerifyResult Result;
|
public EVerifyResult Result;
|
||||||
public string DataFileCRC;
|
public string DataFileCRC;
|
||||||
public long DataFileSize;
|
public long DataFileSize;
|
||||||
|
|
||||||
public VerifyElement(string packageName, string cacheGUID, string fileRootPath, string dataFilePath, string infoFilePath)
|
public VerifyCacheElement(string packageName, string cacheGUID, string fileRootPath, string dataFilePath, string infoFilePath)
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
CacheGUID = cacheGUID;
|
CacheGUID = cacheGUID;
|
||||||
@@ -36,4 +39,23 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载文件验证元素
|
||||||
|
/// </summary>
|
||||||
|
internal class VerifyTempElement
|
||||||
|
{
|
||||||
|
public string TempDataFilePath { private set; get; }
|
||||||
|
public string FileCRC { private set; get; }
|
||||||
|
public long FileSize { private set; get; }
|
||||||
|
|
||||||
|
public EVerifyResult Result;
|
||||||
|
|
||||||
|
public VerifyTempElement(string tempDataFilePath, string fileCRC, long fileSize)
|
||||||
|
{
|
||||||
|
TempDataFilePath = tempDataFilePath;
|
||||||
|
FileCRC = fileCRC;
|
||||||
|
FileSize = fileSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,16 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义下载器的请求委托
|
||||||
|
/// </summary>
|
||||||
|
public delegate UnityWebRequest DownloadRequestDelegate(string url);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 1. 保证每一时刻资源文件只存在一个下载器
|
/// 1. 保证每一时刻资源文件只存在一个下载器
|
||||||
/// 2. 保证下载器下载完成后立刻验证并缓存
|
/// 2. 保证下载器下载完成后立刻验证并缓存
|
||||||
@@ -16,11 +22,20 @@ namespace YooAsset
|
|||||||
private static readonly Dictionary<string, DownloaderBase> _downloaderDic = new Dictionary<string, DownloaderBase>();
|
private static readonly Dictionary<string, DownloaderBase> _downloaderDic = new Dictionary<string, DownloaderBase>();
|
||||||
private static readonly List<string> _removeList = new List<string>(100);
|
private static readonly List<string> _removeList = new List<string>(100);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 线程同步
|
||||||
|
/// </summary>
|
||||||
|
public static ThreadSyncContext SyncContext { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义下载器的请求委托
|
||||||
|
/// </summary>
|
||||||
|
public static DownloadRequestDelegate RequestDelegate = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义的证书认证实例
|
/// 自定义的证书认证实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static CertificateHandler CertificateHandlerInstance;
|
public static CertificateHandler CertificateHandlerInstance = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用断点续传功能文件的最小字节数
|
/// 启用断点续传功能文件的最小字节数
|
||||||
@@ -32,11 +47,23 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<long> ClearFileResponseCodes { set; get; }
|
public static List<long> ClearFileResponseCodes { set; get; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新所有下载器
|
/// 初始化下载器
|
||||||
|
/// </summary>
|
||||||
|
public static void Initialize()
|
||||||
|
{
|
||||||
|
SyncContext = new ThreadSyncContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新下载器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Update()
|
public static void Update()
|
||||||
{
|
{
|
||||||
|
if (SyncContext != null)
|
||||||
|
SyncContext.Update();
|
||||||
|
|
||||||
// 更新下载器
|
// 更新下载器
|
||||||
_removeList.Clear();
|
_removeList.Clear();
|
||||||
foreach (var valuePair in _downloaderDic)
|
foreach (var valuePair in _downloaderDic)
|
||||||
@@ -66,7 +93,12 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
_downloaderDic.Clear();
|
_downloaderDic.Clear();
|
||||||
_removeList.Clear();
|
_removeList.Clear();
|
||||||
|
|
||||||
|
SyncContext = null;
|
||||||
|
RequestDelegate = null;
|
||||||
|
CertificateHandlerInstance = null;
|
||||||
BreakpointResumeFileSize = int.MaxValue;
|
BreakpointResumeFileSize = int.MaxValue;
|
||||||
|
ClearFileResponseCodes = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -101,6 +133,18 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建一个新的网络请求
|
||||||
|
/// </summary>
|
||||||
|
public static UnityWebRequest NewRequest(string requestURL)
|
||||||
|
{
|
||||||
|
if (RequestDelegate != null)
|
||||||
|
return RequestDelegate.Invoke(requestURL);
|
||||||
|
|
||||||
|
var request = new UnityWebRequest(requestURL, UnityWebRequest.kHttpVerbGET);
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取下载器的总数
|
/// 获取下载器的总数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
CheckTempFile,
|
CheckTempFile,
|
||||||
|
WaitingCheckTempFile,
|
||||||
PrepareDownload,
|
PrepareDownload,
|
||||||
CreateResumeDownloader,
|
CreateResumeDownloader,
|
||||||
CreateGeneralDownloader,
|
CreateGeneralDownloader,
|
||||||
CheckDownload,
|
CheckDownload,
|
||||||
VerifyingFile,
|
VerifyTempFile,
|
||||||
|
WaitingVerifyTempFile,
|
||||||
CachingFile,
|
CachingFile,
|
||||||
TryAgain,
|
TryAgain,
|
||||||
Succeed,
|
Succeed,
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ namespace YooAsset
|
|||||||
private readonly string _tempFilePath;
|
private readonly string _tempFilePath;
|
||||||
private UnityWebRequest _webRequest = null;
|
private UnityWebRequest _webRequest = null;
|
||||||
private DownloadHandlerFileRange _downloadHandle = null;
|
private DownloadHandlerFileRange _downloadHandle = null;
|
||||||
|
private VerifyTempFileOperation _checkFileOp = null;
|
||||||
|
private VerifyTempFileOperation _verifyFileOp = null;
|
||||||
|
|
||||||
// 重置变量
|
// 重置变量
|
||||||
private bool _isAbort = false;
|
private bool _isAbort = false;
|
||||||
@@ -34,17 +36,28 @@ namespace YooAsset
|
|||||||
if (IsDone())
|
if (IsDone())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 检测本地临时文件
|
// 检测临时文件
|
||||||
if (_steps == ESteps.CheckTempFile)
|
if (_steps == ESteps.CheckTempFile)
|
||||||
{
|
{
|
||||||
var verifyResult = CacheSystem.VerifyingTempFile(_bundleInfo.Bundle);
|
VerifyTempElement element = new VerifyTempElement(_bundleInfo.Bundle.TempDataFilePath, _bundleInfo.Bundle.FileCRC, _bundleInfo.Bundle.FileSize);
|
||||||
if (verifyResult == EVerifyResult.Succeed)
|
_checkFileOp = VerifyTempFileOperation.CreateOperation(element);
|
||||||
|
OperationSystem.StartOperation(_checkFileOp);
|
||||||
|
_steps = ESteps.WaitingCheckTempFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 等待检测结果
|
||||||
|
if (_steps == ESteps.WaitingCheckTempFile)
|
||||||
|
{
|
||||||
|
if (_checkFileOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_checkFileOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.CachingFile;
|
_steps = ESteps.CachingFile;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (verifyResult == EVerifyResult.FileOverflow)
|
if (_checkFileOp.VerifyResult == EVerifyResult.FileOverflow)
|
||||||
{
|
{
|
||||||
if (File.Exists(_tempFilePath))
|
if (File.Exists(_tempFilePath))
|
||||||
File.Delete(_tempFilePath);
|
File.Delete(_tempFilePath);
|
||||||
@@ -80,7 +93,7 @@ namespace YooAsset
|
|||||||
if (File.Exists(_tempFilePath))
|
if (File.Exists(_tempFilePath))
|
||||||
File.Delete(_tempFilePath);
|
File.Delete(_tempFilePath);
|
||||||
|
|
||||||
_webRequest = new UnityWebRequest(_requestURL, UnityWebRequest.kHttpVerbGET);
|
_webRequest = DownloadSystem.NewRequest(_requestURL);
|
||||||
DownloadHandlerFile handler = new DownloadHandlerFile(_tempFilePath);
|
DownloadHandlerFile handler = new DownloadHandlerFile(_tempFilePath);
|
||||||
handler.removeFileOnAbort = true;
|
handler.removeFileOnAbort = true;
|
||||||
_webRequest.downloadHandler = handler;
|
_webRequest.downloadHandler = handler;
|
||||||
@@ -109,11 +122,11 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_2019_4_OR_NEWER
|
#if UNITY_2019_4_OR_NEWER
|
||||||
_webRequest = new UnityWebRequest(_requestURL, UnityWebRequest.kHttpVerbGET);
|
_webRequest = DownloadSystem.NewRequest(_requestURL);
|
||||||
var handler = new DownloadHandlerFile(_tempFilePath, true);
|
var handler = new DownloadHandlerFile(_tempFilePath, true);
|
||||||
handler.removeFileOnAbort = false;
|
handler.removeFileOnAbort = false;
|
||||||
#else
|
#else
|
||||||
_webRequest = new UnityWebRequest(_requestURL, UnityWebRequest.kHttpVerbGET);
|
_webRequest = DownloadSystem.NewRequest(_requestURL);
|
||||||
var handler = new DownloadHandlerFileRange(_tempFilePath, _bundleInfo.Bundle.FileSize, _webRequest);
|
var handler = new DownloadHandlerFileRange(_tempFilePath, _bundleInfo.Bundle.FileSize, _webRequest);
|
||||||
_downloadHandle = handler;
|
_downloadHandle = handler;
|
||||||
#endif
|
#endif
|
||||||
@@ -188,7 +201,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.VerifyingFile;
|
_steps = ESteps.VerifyTempFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 释放下载器
|
// 释放下载器
|
||||||
@@ -196,21 +209,30 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 验证下载文件
|
// 验证下载文件
|
||||||
if (_steps == ESteps.VerifyingFile)
|
if (_steps == ESteps.VerifyTempFile)
|
||||||
{
|
{
|
||||||
var verifyResult = CacheSystem.VerifyingTempFile(_bundleInfo.Bundle);
|
VerifyTempElement element = new VerifyTempElement(_bundleInfo.Bundle.TempDataFilePath, _bundleInfo.Bundle.FileCRC, _bundleInfo.Bundle.FileSize);
|
||||||
if (verifyResult == EVerifyResult.Succeed)
|
_verifyFileOp = VerifyTempFileOperation.CreateOperation(element);
|
||||||
|
OperationSystem.StartOperation(_verifyFileOp);
|
||||||
|
_steps = ESteps.WaitingVerifyTempFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 等待验证完成
|
||||||
|
if (_steps == ESteps.WaitingVerifyTempFile)
|
||||||
|
{
|
||||||
|
if (_verifyFileOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_verifyFileOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.CachingFile;
|
_steps = ESteps.CachingFile;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_lastError = $"Failed to verifying file : {_bundleInfo.Bundle.FileName}, ErrorCode : {verifyResult}";
|
|
||||||
|
|
||||||
// 注意:验证失败后删除文件
|
|
||||||
if (File.Exists(_tempFilePath))
|
if (File.Exists(_tempFilePath))
|
||||||
File.Delete(_tempFilePath);
|
File.Delete(_tempFilePath);
|
||||||
|
|
||||||
|
_lastError = _verifyFileOp.Error;
|
||||||
_steps = ESteps.TryAgain;
|
_steps = ESteps.TryAgain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -226,7 +248,7 @@ namespace YooAsset
|
|||||||
long dataFileSize = _bundleInfo.Bundle.FileSize;
|
long dataFileSize = _bundleInfo.Bundle.FileSize;
|
||||||
|
|
||||||
if (File.Exists(infoFilePath))
|
if (File.Exists(infoFilePath))
|
||||||
File.Delete(infoFilePath);
|
File.Delete(infoFilePath);
|
||||||
if (File.Exists(dataFilePath))
|
if (File.Exists(dataFilePath))
|
||||||
File.Delete(dataFilePath);
|
File.Delete(dataFilePath);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace YooAsset
|
|||||||
if (_webRequest == null)
|
if (_webRequest == null)
|
||||||
{
|
{
|
||||||
URL = url;
|
URL = url;
|
||||||
_webRequest = new UnityWebRequest(URL, UnityWebRequest.kHttpVerbGET);
|
_webRequest = DownloadSystem.NewRequest(URL);
|
||||||
DownloadHandlerBuffer handler = new DownloadHandlerBuffer();
|
DownloadHandlerBuffer handler = new DownloadHandlerBuffer();
|
||||||
_webRequest.downloadHandler = handler;
|
_webRequest.downloadHandler = handler;
|
||||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace YooAsset
|
|||||||
_latestDownloadBytes = 0;
|
_latestDownloadBytes = 0;
|
||||||
_latestDownloadRealtime = Time.realtimeSinceStartup;
|
_latestDownloadRealtime = Time.realtimeSinceStartup;
|
||||||
|
|
||||||
_webRequest = new UnityWebRequest(URL, UnityWebRequest.kHttpVerbGET);
|
_webRequest = DownloadSystem.NewRequest(URL);
|
||||||
DownloadHandlerFile handler = new DownloadHandlerFile(savePath);
|
DownloadHandlerFile handler = new DownloadHandlerFile(savePath);
|
||||||
handler.removeFileOnAbort = true;
|
handler.removeFileOnAbort = true;
|
||||||
_webRequest.downloadHandler = handler;
|
_webRequest.downloadHandler = handler;
|
||||||
|
|||||||
@@ -32,28 +32,36 @@ namespace YooAsset
|
|||||||
private bool _isPause = false;
|
private bool _isPause = false;
|
||||||
private long _lastDownloadBytes = 0;
|
private long _lastDownloadBytes = 0;
|
||||||
private int _lastDownloadCount = 0;
|
private int _lastDownloadCount = 0;
|
||||||
|
private long _cachedDownloadBytes = 0;
|
||||||
|
private int _cachedDownloadCount = 0;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载文件总数量
|
/// 统计的下载文件总数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TotalDownloadCount { private set; get; }
|
public int TotalDownloadCount { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载文件的总大小
|
/// 统计的下载文件的总大小
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long TotalDownloadBytes { private set; get; }
|
public long TotalDownloadBytes { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前已经完成的下载总数量
|
/// 当前已经完成的下载总数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CurrentDownloadCount { private set; get; }
|
public int CurrentDownloadCount
|
||||||
|
{
|
||||||
|
get { return _lastDownloadCount; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前已经完成的下载总大小
|
/// 当前已经完成的下载总大小
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long CurrentDownloadBytes { private set; get; }
|
public long CurrentDownloadBytes
|
||||||
|
{
|
||||||
|
get { return _lastDownloadBytes; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当下载器结束(无论成功或失败)
|
/// 当下载器结束(无论成功或失败)
|
||||||
@@ -120,7 +128,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
// 检测下载器结果
|
// 检测下载器结果
|
||||||
_removeList.Clear();
|
_removeList.Clear();
|
||||||
long downloadBytes = CurrentDownloadBytes;
|
long downloadBytes = _cachedDownloadBytes;
|
||||||
foreach (var downloader in _downloaders)
|
foreach (var downloader in _downloaders)
|
||||||
{
|
{
|
||||||
downloadBytes += (long)downloader.DownloadedBytes;
|
downloadBytes += (long)downloader.DownloadedBytes;
|
||||||
@@ -139,8 +147,8 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 下载成功
|
// 下载成功
|
||||||
_removeList.Add(downloader);
|
_removeList.Add(downloader);
|
||||||
CurrentDownloadCount++;
|
_cachedDownloadCount++;
|
||||||
CurrentDownloadBytes += bundleInfo.Bundle.FileSize;
|
_cachedDownloadBytes += bundleInfo.Bundle.FileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除已经完成的下载器(无论成功或失败)
|
// 移除已经完成的下载器(无论成功或失败)
|
||||||
@@ -150,10 +158,10 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 如果下载进度发生变化
|
// 如果下载进度发生变化
|
||||||
if (_lastDownloadBytes != downloadBytes || _lastDownloadCount != CurrentDownloadCount)
|
if (_lastDownloadBytes != downloadBytes || _lastDownloadCount != _cachedDownloadCount)
|
||||||
{
|
{
|
||||||
_lastDownloadBytes = downloadBytes;
|
_lastDownloadBytes = downloadBytes;
|
||||||
_lastDownloadCount = CurrentDownloadCount;
|
_lastDownloadCount = _cachedDownloadCount;
|
||||||
Progress = (float)_lastDownloadBytes / TotalDownloadBytes;
|
Progress = (float)_lastDownloadBytes / TotalDownloadBytes;
|
||||||
OnDownloadProgressCallback?.Invoke(TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes);
|
OnDownloadProgressCallback?.Invoke(TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int[] ReferenceIDs;
|
public int[] ReferenceIDs;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属的包裹名称
|
/// 所属的包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -71,8 +71,17 @@ namespace YooAsset
|
|||||||
if (string.IsNullOrEmpty(_cachedDataFilePath) == false)
|
if (string.IsNullOrEmpty(_cachedDataFilePath) == false)
|
||||||
return _cachedDataFilePath;
|
return _cachedDataFilePath;
|
||||||
|
|
||||||
string cacheRoot = PersistentHelper.GetCacheFolderPath(PackageName);
|
string folderName = FileHash.Substring(0, 2);
|
||||||
_cachedDataFilePath = $"{cacheRoot}/{CacheGUID}/{YooAssetSettings.CacheBundleDataFileName}{_fileExtension}";
|
if (IsRawFile)
|
||||||
|
{
|
||||||
|
string cacheRoot = PersistentHelper.GetCachedRawFileFolderPath(PackageName);
|
||||||
|
_cachedDataFilePath = $"{cacheRoot}/{folderName}/{CacheGUID}/{YooAssetSettings.CacheBundleDataFileName}{_fileExtension}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string cacheRoot = PersistentHelper.GetCachedBundleFileFolderPath(PackageName);
|
||||||
|
_cachedDataFilePath = $"{cacheRoot}/{folderName}/{CacheGUID}/{YooAssetSettings.CacheBundleDataFileName}";
|
||||||
|
}
|
||||||
return _cachedDataFilePath;
|
return _cachedDataFilePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,8 +97,17 @@ namespace YooAsset
|
|||||||
if (string.IsNullOrEmpty(_cachedInfoFilePath) == false)
|
if (string.IsNullOrEmpty(_cachedInfoFilePath) == false)
|
||||||
return _cachedInfoFilePath;
|
return _cachedInfoFilePath;
|
||||||
|
|
||||||
string cacheRoot = PersistentHelper.GetCacheFolderPath(PackageName);
|
string folderName = FileHash.Substring(0, 2);
|
||||||
_cachedInfoFilePath = $"{cacheRoot}/{CacheGUID}/{YooAssetSettings.CacheBundleInfoFileName}";
|
if (IsRawFile)
|
||||||
|
{
|
||||||
|
string cacheRoot = PersistentHelper.GetCachedRawFileFolderPath(PackageName);
|
||||||
|
_cachedInfoFilePath = $"{cacheRoot}/{folderName}/{CacheGUID}/{YooAssetSettings.CacheBundleInfoFileName}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string cacheRoot = PersistentHelper.GetCachedBundleFileFolderPath(PackageName);
|
||||||
|
_cachedInfoFilePath = $"{cacheRoot}/{folderName}/{CacheGUID}/{YooAssetSettings.CacheBundleInfoFileName}";
|
||||||
|
}
|
||||||
return _cachedInfoFilePath;
|
return _cachedInfoFilePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ namespace YooAsset
|
|||||||
internal static class PersistentHelper
|
internal static class PersistentHelper
|
||||||
{
|
{
|
||||||
private const string CacheFolderName = "CacheFiles";
|
private const string CacheFolderName = "CacheFiles";
|
||||||
|
private const string CachedBundleFileFolder = "BundleFiles";
|
||||||
|
private const string CachedRawFileFolder = "RawFiles";
|
||||||
private const string ManifestFolderName = "ManifestFiles";
|
private const string ManifestFolderName = "ManifestFiles";
|
||||||
private const string AppFootPrintFileName = "ApplicationFootPrint.bytes";
|
private const string AppFootPrintFileName = "ApplicationFootPrint.bytes";
|
||||||
|
|
||||||
@@ -120,12 +122,33 @@ namespace YooAsset
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取缓存文件夹路径
|
/// 获取缓存的BundleFile文件夹路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetCacheFolderPath(string packageName)
|
private readonly static Dictionary<string, string> _cachedBundleFileFolder = new Dictionary<string, string>(100);
|
||||||
|
public static string GetCachedBundleFileFolderPath(string packageName)
|
||||||
{
|
{
|
||||||
string root = PathHelper.MakePersistentLoadPath(CacheFolderName);
|
if (_cachedBundleFileFolder.TryGetValue(packageName, out string value) == false)
|
||||||
return $"{root}/{packageName}";
|
{
|
||||||
|
string root = PathHelper.MakePersistentLoadPath(CacheFolderName);
|
||||||
|
value = $"{root}/{packageName}/{CachedBundleFileFolder}";
|
||||||
|
_cachedBundleFileFolder.Add(packageName, value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存的RawFile文件夹路径
|
||||||
|
/// </summary>
|
||||||
|
private readonly static Dictionary<string, string> _cachedRawFileFolder = new Dictionary<string, string>(100);
|
||||||
|
public static string GetCachedRawFileFolderPath(string packageName)
|
||||||
|
{
|
||||||
|
if (_cachedRawFileFolder.TryGetValue(packageName, out string value) == false)
|
||||||
|
{
|
||||||
|
string root = PathHelper.MakePersistentLoadPath(CacheFolderName);
|
||||||
|
value = $"{root}/{packageName}/{CachedRawFileFolder}";
|
||||||
|
_cachedRawFileFolder.Add(packageName, value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ namespace YooAsset
|
|||||||
_driver.AddComponent<RemoteDebuggerInRuntime>();
|
_driver.AddComponent<RemoteDebuggerInRuntime>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 初始化异步系统
|
|
||||||
OperationSystem.Initialize();
|
OperationSystem.Initialize();
|
||||||
|
DownloadSystem.Initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +184,14 @@ namespace YooAsset
|
|||||||
DownloadSystem.CertificateHandlerInstance = instance;
|
DownloadSystem.CertificateHandlerInstance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置下载系统参数,自定义下载请求
|
||||||
|
/// </summary>
|
||||||
|
public static void SetDownloadSystemUnityWebRequest(DownloadRequestDelegate requestDelegate)
|
||||||
|
{
|
||||||
|
DownloadSystem.RequestDelegate = requestDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置异步系统参数,每帧执行消耗的最大时间切片(单位:毫秒)
|
/// 设置异步系统参数,每帧执行消耗的最大时间切片(单位:毫秒)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ MonoBehaviour:
|
|||||||
BuildMode: 0
|
BuildMode: 0
|
||||||
BuildPackage: DefaultPackage
|
BuildPackage: DefaultPackage
|
||||||
CompressOption: 2
|
CompressOption: 2
|
||||||
OutputNameStyle: 4
|
OutputNameStyle: 1
|
||||||
CopyBuildinFileOption: 1
|
CopyBuildinFileOption: 1
|
||||||
CopyBuildinFileTags:
|
CopyBuildinFileTags:
|
||||||
EncyptionClassName: FileStreamEncryption
|
EncyptionClassName: FileStreamEncryption
|
||||||
|
|||||||
@@ -12,4 +12,6 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 44454e58a49818040a1aef5799e71b30, type: 3}
|
m_Script: {fileID: 11500000, guid: 44454e58a49818040a1aef5799e71b30, type: 3}
|
||||||
m_Name: ShaderVariantCollectorSetting
|
m_Name: ShaderVariantCollectorSetting
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
SavePath: Assets/Samples/BassicSample/GameArt/ShaderVariants/MyShaderVariants.shadervariants
|
SavePath: Assets/ShaderVariants/MyShaderVariants.shadervariants
|
||||||
|
CollectPackage: DefaultPackage
|
||||||
|
ProcessCapacity: 1000
|
||||||
|
|||||||
@@ -3,21 +3,11 @@ using System.IO;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using YooAsset;
|
using YooAsset;
|
||||||
|
|
||||||
public class EncryptionNone : IEncryptionServices
|
|
||||||
{
|
|
||||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
|
||||||
{
|
|
||||||
EncryptResult result = new EncryptResult();
|
|
||||||
result.LoadMethod = EBundleLoadMethod.Normal;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FileOffsetEncryption : IEncryptionServices
|
public class FileOffsetEncryption : IEncryptionServices
|
||||||
{
|
{
|
||||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||||
{
|
{
|
||||||
if(fileInfo.BundleName.Contains("gameres_music"))
|
if (fileInfo.BundleName.Contains("_gameres_audio"))
|
||||||
{
|
{
|
||||||
int offset = 32;
|
int offset = 32;
|
||||||
byte[] fileData = File.ReadAllBytes(fileInfo.FilePath);
|
byte[] fileData = File.ReadAllBytes(fileInfo.FilePath);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// 作者:Stark
|
// 作者:Stark
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
|
|
||||||
|
#if UNITY_ANDROID
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 为Github对开发者的友好,采用自动补充UnityPlayerActivity.java文件的通用姿势满足各个开发者
|
/// 为Github对开发者的友好,采用自动补充UnityPlayerActivity.java文件的通用姿势满足各个开发者
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -34,11 +35,24 @@ internal class AndroidPost : UnityEditor.Android.IPostGenerateGradleAndroidProje
|
|||||||
" return false; \n" +
|
" return false; \n" +
|
||||||
" } \n" +
|
" } \n" +
|
||||||
"}";
|
"}";
|
||||||
if (!readContent[readContent.Length - 18].Contains("CheckAssetExist"))
|
|
||||||
|
if (CheckFunctionExist(readContent) == false)
|
||||||
readContent[readContent.Length - 1] = postContent;
|
readContent[readContent.Length - 1] = postContent;
|
||||||
System.IO.File.WriteAllLines(untityActivityFilePath, readContent);
|
System.IO.File.WriteAllLines(untityActivityFilePath, readContent);
|
||||||
}
|
}
|
||||||
|
private bool CheckFunctionExist(string[] contents)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < contents.Length; i++)
|
||||||
|
{
|
||||||
|
if (contents[i].Contains("CheckAssetExist"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//auto-gen-function
|
//auto-gen-function
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.4.6-preview",
|
"version": "1.4.7",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 资源构建
|
# 资源构建
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 界面介绍
|
### 界面介绍
|
||||||
|
|
||||||
@@ -50,9 +50,7 @@
|
|||||||
|
|
||||||
HashName:哈希值
|
HashName:哈希值
|
||||||
|
|
||||||
HashName_Extension:哈希值+后缀名
|
BundleName_HashName:资源包名+哈希值
|
||||||
|
|
||||||
HashName_BundleName_Extension:资源包名+哈希值+后缀名
|
|
||||||
|
|
||||||
- **Copy Buildin File Option**
|
- **Copy Buildin File Option**
|
||||||
|
|
||||||
@@ -78,17 +76,23 @@
|
|||||||
|
|
||||||
补丁包文件夹里包含补丁清单文件,资源包文件,构建报告文件等。
|
补丁包文件夹里包含补丁清单文件,资源包文件,构建报告文件等。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 补丁清单
|
### 补丁清单
|
||||||
|
|
||||||
补丁清单是一个Json格式的文本文件。
|
补丁清单文件是上图中以PatchManifest开头命名的文件。
|
||||||
|
|
||||||
AssetList组记录的是主资源对象列表。
|
- PatchManifest_DefaultPackage_xxxxxx.hash
|
||||||
|
|
||||||
BundleList组记录的是资源包列表。
|
记录了补丁清单文件的哈希值。
|
||||||
|
|
||||||

|
- PatchManifest_DefaultPackage_xxxxxx.json
|
||||||
|
|
||||||
|
该文件为Json文本格式,主要用于开发者预览信息。
|
||||||
|
|
||||||
|
- PatchManifest_DefaultPackage_xxxxxx.bytes
|
||||||
|
|
||||||
|
该文件为二进制格式,主要用于程序内读取加载。
|
||||||
|
|
||||||
### Jenkins支持
|
### Jenkins支持
|
||||||
|
|
||||||
@@ -109,10 +113,10 @@ private static void BuildInternal(BuildTarget buildTarget)
|
|||||||
buildParameters.BuildPipeline = EBuildPipeline.BuiltinBuildPipeline;
|
buildParameters.BuildPipeline = EBuildPipeline.BuiltinBuildPipeline;
|
||||||
buildParameters.BuildMode = EBuildMode.ForceRebuild;
|
buildParameters.BuildMode = EBuildMode.ForceRebuild;
|
||||||
buildParameters.PackageName = "DefaultPackage";
|
buildParameters.PackageName = "DefaultPackage";
|
||||||
buildParameters.PackageVersion = "1.0.0";
|
buildParameters.PackageVersion = "1.0";
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.CompressOption = ECompressOption.LZ4;
|
buildParameters.CompressOption = ECompressOption.LZ4;
|
||||||
buildParameters.OutputNameStyle = EOutputNameStyle.HashName_Extension;
|
buildParameters.OutputNameStyle = EOutputNameStyle.HashName;
|
||||||
buildParameters.CopyBuildinFileOption = ECopyBuildinFileOption.None;
|
buildParameters.CopyBuildinFileOption = ECopyBuildinFileOption.None;
|
||||||
|
|
||||||
// 执行构建
|
// 执行构建
|
||||||
@@ -122,6 +126,10 @@ private static void BuildInternal(BuildTarget buildTarget)
|
|||||||
{
|
{
|
||||||
Debug.Log($"构建成功 : {buildResult.OutputPackageDirectory}");
|
Debug.Log($"构建成功 : {buildResult.OutputPackageDirectory}");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError($"构建失败 : {buildResult.FailedInfo}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从构建命令里获取参数示例
|
// 从构建命令里获取参数示例
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
# 资源收集
|
# 资源收集
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
左侧为分组列表,右侧为该分组的配置界面。
|
左侧为分组列表,右侧为该分组的配置界面。
|
||||||
|
|
||||||
导出按钮可以将配置数据导出为XML文件,导入按钮可以导入保存的XML文件。
|
导入按钮:可以导入保存的XML文件。
|
||||||
|
|
||||||
|
导出按钮:可以将配置数据导出为XML文件。
|
||||||
|
|
||||||
|
修复按钮:在配置里的文件夹挪动位置之后,可以通过该按钮按钮来修正。
|
||||||
|
|
||||||
**注意**:该工具仅支持Unity2019.4+
|
**注意**:该工具仅支持Unity2019.4+
|
||||||
|
|
||||||
@@ -13,11 +17,15 @@
|
|||||||
- Show Packages
|
- Show Packages
|
||||||
|
|
||||||
是否展示资源包列表视图。
|
是否展示资源包列表视图。
|
||||||
|
|
||||||
|
- Show Editor Alias
|
||||||
|
|
||||||
|
是否显示为中文模式。
|
||||||
|
|
||||||
- Enable Addressable
|
- Enable Addressable
|
||||||
|
|
||||||
启用可寻址资源定位系统。
|
启用可寻址资源定位系统。
|
||||||
|
|
||||||
- Unique Bundle Name
|
- Unique Bundle Name
|
||||||
|
|
||||||
资源包名追加PackageName作为前缀。
|
资源包名追加PackageName作为前缀。
|
||||||
@@ -36,10 +44,10 @@
|
|||||||
//自定义扩展范例
|
//自定义扩展范例
|
||||||
public class DisableGroup : IActiveRule
|
public class DisableGroup : IActiveRule
|
||||||
{
|
{
|
||||||
public bool IsActiveGroup()
|
public bool IsActiveGroup()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
@@ -83,18 +91,18 @@
|
|||||||
|
|
||||||
- AddressByFileName 以文件名为定位地址。
|
- AddressByFileName 以文件名为定位地址。
|
||||||
|
|
||||||
- AddressByGrouperAndFileName 以分组名称+文件名为定位地址。
|
- AddressByGrouperAndFileName 以分组名+文件名为定位地址。
|
||||||
|
|
||||||
- AddressByCollectorAndFileName 以收集器名+文件名为定位地址。
|
- AddressByFolderAndFileName 以文件夹名+文件名为定位地址。
|
||||||
|
|
||||||
````c#
|
````c#
|
||||||
//自定义扩展范例
|
//自定义扩展范例
|
||||||
public class AddressByFileName : IAddressRule
|
public class AddressByFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
{
|
{
|
||||||
return Path.GetFileNameWithoutExtension(data.AssetPath);
|
return Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
@@ -102,21 +110,28 @@
|
|||||||
|
|
||||||
打包规则,规则可以自定义扩展。下面是内置规则:
|
打包规则,规则可以自定义扩展。下面是内置规则:
|
||||||
|
|
||||||
- PackSeparately 以收集文件路径作为资源包名,每个资源文件单独打包。
|
- PackSeparately 以文件路径作为资源包名,每个资源文件单独打包。
|
||||||
- PackDirectory 以收集文件所在的文件夹路径作为资源包名,该文件夹下所有文件打进一个资源包。
|
- PackDirectory 以文件所在的文件夹路径作为资源包名,该文件夹下所有文件打进一个资源包。
|
||||||
- PackTopDirectory 以收集器路径下顶级文件夹为资源包名,该文件夹下所有文件打进一个资源包。
|
- PackTopDirectory 以收集器下顶级文件夹为资源包名,该文件夹下所有文件打进一个资源包。
|
||||||
- PackCollector 以收集器路径作为资源包名,收集的所有文件打进一个资源包。
|
- PackCollector 以收集器路径作为资源包名,收集的所有文件打进一个资源包。
|
||||||
- PackGrouper 以分组名称作为资源包名,收集的所有文件打进一个资源包。
|
- PackGroup 以分组名称作为资源包名,收集的所有文件打进一个资源包。
|
||||||
- PackRawFile 目录下的资源文件会被处理为原生资源包。
|
- PackRawFile 目录下的资源文件会被处理为原生资源包。
|
||||||
|
|
||||||
````c#
|
````c#
|
||||||
//自定义扩展范例
|
//自定义扩展范例
|
||||||
public class PackDirectory : IPackRule
|
public class PackDirectory : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
PackRuleResult IPackRule.GetBundleName(PackRuleData data)
|
||||||
{
|
{
|
||||||
return Path.GetDirectoryName(data.AssetPath); //"Assets/Config/test.txt" --> "Assets/Config"
|
//"Assets/Config/test.txt" --> "Assets/Config"
|
||||||
}
|
string bundleName = Path.GetDirectoryName(data.AssetPath);
|
||||||
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
bool IPackRule.IsRawFilePackRule()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
@@ -133,13 +148,17 @@
|
|||||||
//自定义扩展范例
|
//自定义扩展范例
|
||||||
public class CollectScene : IFilterRule
|
public class CollectScene : IFilterRule
|
||||||
{
|
{
|
||||||
public bool IsCollectAsset(FilterRuleData data)
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
{
|
{
|
||||||
return Path.GetExtension(data.AssetPath) == ".unity";
|
return Path.GetExtension(data.AssetPath) == ".unity";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
|
- **UserData**
|
||||||
|
|
||||||
|
用户自定义数据,可以帮助定制化AddressRule和PackRule。
|
||||||
|
|
||||||
- **AssetTags**
|
- **AssetTags**
|
||||||
|
|
||||||
资源分类标签列表,该收集器下收集的资源会全部被打上该标签。
|
资源分类标签列表,该收集器下收集的资源会全部被打上该标签。
|
||||||
|
|||||||
@@ -4,22 +4,40 @@
|
|||||||
|
|
||||||
如果是本地测试,可以在本地创建一个WEB服务器,然后将补丁包拷贝到WEB服务器下。
|
如果是本地测试,可以在本地创建一个WEB服务器,然后将补丁包拷贝到WEB服务器下。
|
||||||
|
|
||||||
**按照游戏版本目录部署**
|
**部署目录**
|
||||||
|
|
||||||
在业务开发过程中,每个游戏版本实际都会创建一个SVN分支,该分支工程内每次构建的补丁包上传到对应的CDN目录下即可。
|
在业务开发过程中,发版本之前都会创建一个SVN或GIT分支,以分支工程为基础去构建APP。
|
||||||
|
|
||||||
````
|
````
|
||||||
CDN
|
CDN
|
||||||
└─android
|
└─android
|
||||||
├─v1.0
|
├─v1.0(APP版本)
|
||||||
├─v1.1
|
├─v1.1(APP版本)
|
||||||
└─v2.0
|
└─v2.0(APP版本)
|
||||||
└─iphone
|
└─iphone
|
||||||
├─v1.0
|
├─v1.0(APP版本)
|
||||||
├─v1.1
|
├─v1.1(APP版本)
|
||||||
└─v2.0
|
└─v2.0(APP版本)
|
||||||
````
|
````
|
||||||
|
|
||||||
**游戏版本说明**
|
**APP版本说明**
|
||||||
|
|
||||||
|
v1.0 代表的是APP版本,不是资源版本。在没有更换安装包的情况下,不需要新增加APP版本目录。
|
||||||
|
|
||||||
|
例如:我们游戏的当前APP版本是v1.0,那么每次生成的补丁文件全部覆盖到v1.0的目录下即可。
|
||||||
|
|
||||||
|
下面的示例里一共上传过2次补丁包。第二次上传的补丁包会把第一次的版本记录文件(PatchManifest_DefaultPackage.version)覆盖掉。当我们想回退资源版本的时候,把第一次生成的版本记录文件覆盖到同目录下即可。
|
||||||
|
|
||||||
|
````
|
||||||
|
v1.0(游戏版本)
|
||||||
|
├─PatchManifest_DefaultPackage.version
|
||||||
|
├─PatchManifest_DefaultPackage_2023-02-01-654.hash
|
||||||
|
├─PatchManifest_DefaultPackage_2023-02-01-654.bytes
|
||||||
|
├─PatchManifest_DefaultPackage_2023-02-12-789.hash
|
||||||
|
├─PatchManifest_DefaultPackage_2023-02-12-789.bytes
|
||||||
|
├─2bb5a28d37dabf27df8bc6a4706b8f80.bundle
|
||||||
|
├─2dbea9c3056c8839bc03d80a2aebd105.bundle
|
||||||
|
├─6e8c3003a64ead36a0bd2d5cdebfbcf4.bundle
|
||||||
|
...
|
||||||
|
````
|
||||||
|
|
||||||
v1.0 代表的是游戏版本,不是资源版本。在没有更换安装包的前提下,不需要递增这个游戏版本。每次生成的补丁包只需要覆盖掉当前游戏版本目录下即可。
|
|
||||||
|
|||||||
@@ -73,15 +73,17 @@ private class QueryStreamingAssetsFileServices : IQueryServices
|
|||||||
{
|
{
|
||||||
public bool QueryStreamingAssets(string fileName)
|
public bool QueryStreamingAssets(string fileName)
|
||||||
{
|
{
|
||||||
// 注意:使用了BetterStreamingAssets插件,使用前需要初始化该插件!
|
// StreamingAssetsHelper.cs是太空战机里提供的一个查询脚本。
|
||||||
string buildinFolderName = YooAssets.GetStreamingAssetBuildinFolderName();
|
string buildinFolderName = YooAssets.GetStreamingAssetBuildinFolderName();
|
||||||
return BetterStreamingAssets.FileExists($"{buildinFolderName}/{fileName}");
|
return StreamingAssetsHelper.FileExists($"{buildinFolderName}/{fileName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
### 源代码解析
|
### 源代码解析
|
||||||
|
|
||||||
|
Package.InitializeAsync()方法解析。
|
||||||
|
|
||||||
- 编辑器模拟模式
|
- 编辑器模拟模式
|
||||||
|
|
||||||
每次启动调用EditorSimulateModeHelper.SimulateBuild()方法,都会在底层执行一次模拟构建(Simulate Build)。
|
每次启动调用EditorSimulateModeHelper.SimulateBuild()方法,都会在底层执行一次模拟构建(Simulate Build)。
|
||||||
@@ -90,11 +92,11 @@ private class QueryStreamingAssetsFileServices : IQueryServices
|
|||||||
|
|
||||||
- 单机运行模式
|
- 单机运行模式
|
||||||
|
|
||||||
在初始化的时候,会直接读取内置清单文件(StreamingAssets文件夹里的文件),最后根据加载的清单去验证沙盒里缓存的文件。
|
在初始化的时候,会直接读取内置清单文件(StreamingAssets文件夹里的文件),最后初始化缓存系统。
|
||||||
|
|
||||||
- 联机运行模式
|
- 联机运行模式
|
||||||
|
|
||||||
在初始化的时候,会优先从沙盒里加载清单,如果沙盒里不存在,则会尝试加载内置清单并将其拷贝到沙盒里。最后根据加载的清单去验证沙盒里缓存的文件。
|
在初始化的时候,会优先从沙盒里加载清单,如果沙盒里不存在,则会尝试加载内置清单并将其拷贝到沙盒里。最后初始化缓存系统。
|
||||||
|
|
||||||
**注意**:如果沙盒清单和内置清单都不存在,初始化也会被判定为成功!
|
**注意**:如果沙盒清单和内置清单都不存在,初始化也会被判定为成功!
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ private IEnumerator UpdateStaticVersion()
|
|||||||
if (operation.Status == EOperationStatus.Succeed)
|
if (operation.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
//更新成功
|
//更新成功
|
||||||
string PackageVersion = operation.PackageVersion;
|
string packageVersion = operation.PackageVersion;
|
||||||
Debug.Log($"Updated package Version : {PackageVersion}");
|
Debug.Log($"Updated package Version : {packageVersion}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ private IEnumerator UpdatePatchManifest()
|
|||||||
|
|
||||||
用于下载更新资源标签指定的资源包文件。
|
用于下载更新资源标签指定的资源包文件。
|
||||||
|
|
||||||
- YooAssets.CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
- YooAssets.CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
|
||||||
用于下载更新指定的资源列表依赖的资源包文件。
|
用于下载更新指定的资源列表依赖的资源包文件。
|
||||||
|
|
||||||
@@ -131,25 +131,37 @@ private IEnumerator Start()
|
|||||||
// 如果获取远端资源版本失败,说明当前网络无连接。
|
// 如果获取远端资源版本失败,说明当前网络无连接。
|
||||||
// 在正常开始游戏之前,需要验证本地清单内容的完整性。
|
// 在正常开始游戏之前,需要验证本地清单内容的完整性。
|
||||||
string packageVersion = package.GetPackageVersion();
|
string packageVersion = package.GetPackageVersion();
|
||||||
var operation = package.CheckPackageContentsAsync(packageVersion);
|
var operation = package.PreDownloadPackageAsync(packageVersion);
|
||||||
yield return operation;
|
yield return operation;
|
||||||
if (operation.Status == EOperationStatus.Succeed)
|
if (operation.Status != EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
StartGame();
|
ShowMessageBox("请检查本地网络,有新的游戏内容需要更新!");
|
||||||
|
yield break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
int downloadingMaxNum = 10;
|
||||||
|
int failedTryAgain = 3;
|
||||||
|
int timeout = 60;
|
||||||
|
var downloader = operation.CreatePatchDownloader(downloadingMaxNum, failedTryAgain, timeout);
|
||||||
|
if (downloader.TotalDownloadCount > 0)
|
||||||
{
|
{
|
||||||
// 资源内容本地并不完整,需要提示玩家联网更新。
|
// 资源内容本地并不完整,需要提示玩家联网更新。
|
||||||
ShowMessageBox("请检查本地网络,有新的游戏内容需要更新!");
|
ShowMessageBox("请检查本地网络,有新的游戏内容需要更新!");
|
||||||
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 开始游戏
|
||||||
|
StartGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
### 源代码解析
|
### 源代码解析
|
||||||
|
|
||||||
|
Package.UpdatePackageManifestAsync()方法解析。
|
||||||
|
|
||||||
- 联机运行模式
|
- 联机运行模式
|
||||||
|
|
||||||
UpdatePackageManifestAsync()为资源清单更新方法。该方法的内部实现原理如下:
|
通过传入的清单版本,优先比对当前激活清单的版本,如果相同就直接返回成功。如果有差异就从缓存里去查找匹配的清单,如果缓存里不存在,就去远端下载并保存到沙盒里。最后加载沙盒内匹配的清单文件。
|
||||||
|
|
||||||

|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
- LoadAssetAsync() 异步加载资源对象
|
- LoadAssetAsync() 异步加载资源对象
|
||||||
- LoadSubAssetsSync() 同步加载子资源对象
|
- LoadSubAssetsSync() 同步加载子资源对象
|
||||||
- LoadSubAssetsAsync() 异步加载子资源对象
|
- LoadSubAssetsAsync() 异步加载子资源对象
|
||||||
|
- LoadSceneSync() 同步加载场景
|
||||||
- LoadSceneAsync() 异步加载场景
|
- LoadSceneAsync() 异步加载场景
|
||||||
|
- LoadRawFileSync() 同步获取原生文件
|
||||||
- LoadRawFileAsync() 异步获取原生文件
|
- LoadRawFileAsync() 异步获取原生文件
|
||||||
|
|
||||||
**统一约定**
|
**统一约定**
|
||||||
@@ -152,6 +154,7 @@ IEnumerator Start()
|
|||||||
yield return handle;
|
yield return handle;
|
||||||
byte[] fileData = handle.GetRawFileData();
|
byte[] fileData = handle.GetRawFileData();
|
||||||
string fileText = handle.GetRawFileText();
|
string fileText = handle.GetRawFileText();
|
||||||
|
string filePath = handle.GetRawFilePath();
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
@@ -160,7 +163,7 @@ IEnumerator Start()
|
|||||||
通过资源标签来获取资源信息列表。
|
通过资源标签来获取资源信息列表。
|
||||||
|
|
||||||
````c#
|
````c#
|
||||||
private GetAssetInfosByTag(string tag)
|
void GetAssetInfosByTag(string tag)
|
||||||
{
|
{
|
||||||
AssetInfo[] assetInfos = package.GetAssetInfos(tag);
|
AssetInfo[] assetInfos = package.GetAssetInfos(tag);
|
||||||
foreach (var assetInfo in assetInfos)
|
foreach (var assetInfo in assetInfos)
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ YooAsset依赖于ScriptBuildPipeline(SBP),在PackageManager里找到SBP插
|
|||||||
|
|
||||||
Unity引擎不允许把场景文件和其它资源文件一起打包。
|
Unity引擎不允许把场景文件和其它资源文件一起打包。
|
||||||
|
|
||||||
|
#### 问题:WebGL平台运行时报错:Failed to decompress data for the AssetBundle.
|
||||||
|
|
||||||
|
WebGL平台不支持资源文件加密。在构建选项里,可以将加密方法设置为空
|
||||||
|
|
||||||
#### 问题:ClearCacheWhenDirty参数没了吗?
|
#### 问题:ClearCacheWhenDirty参数没了吗?
|
||||||
|
|
||||||
不是很必须的一个功能,已经移除了。可以使用以下方法代替:
|
不是很必须的一个功能,已经移除了。可以使用以下方法代替:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 全局配置
|
# 全局配置
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
通过右键创建配置文件(Project窗体内右键 -> Create -> YooAsset -> Create Setting)
|
通过右键创建配置文件(Project窗体内右键 -> Create -> YooAsset -> Create Setting)
|
||||||
|
|
||||||
@@ -8,7 +8,5 @@
|
|||||||
|
|
||||||
配置说明:
|
配置说明:
|
||||||
|
|
||||||
- **Asset Bundle File Variant** : AssetBundle资源包后缀名
|
|
||||||
- **Raw File Variant** : 原生资源包后缀名
|
|
||||||
- **Patch Manifest File Name** : 补丁清单文件名称
|
- **Patch Manifest File Name** : 补丁清单文件名称
|
||||||
|
|
||||||
|
|||||||
BIN
Docs/Image/AssetBuilder-img1.jpg
Normal file
|
After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 46 KiB |
BIN
Docs/Image/AssetBuilder-img2.jpg
Normal file
|
After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 48 KiB |
BIN
Docs/Image/AssetCollector-img1.jpg
Normal file
|
After Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 85 KiB |
BIN
Docs/Image/Settings-img1.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 21 KiB |
BIN
Docs/Image/ShaderVariantCollector-img1.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 26 KiB |
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#### 导入流程注意事项
|
#### 导入流程注意事项
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
1. Space Shooter在导入完成后,打开YooAsset->AssetBundle Collector窗口。
|
1. Space Shooter在导入完成后,打开YooAsset->AssetBundle Collector窗口。
|
||||||
1. 点击修复按钮,然后点击Save按钮保存配置,最后关闭窗口。
|
1. 点击修复按钮,然后点击Save按钮保存配置,最后关闭窗口。
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 着色器变种收集
|
# 着色器变种收集
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
点击搜集变种按钮开始收集,请耐心等待结束。
|
点击搜集变种按钮开始收集,请耐心等待结束。
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ YooAsset可以满足以下任何需求:
|
|||||||
5. [构建报告](./Docs/AssetBundleReporter.md)
|
5. [构建报告](./Docs/AssetBundleReporter.md)
|
||||||
5. [调试器](./Docs/AssetBundleDebugger.md)
|
5. [调试器](./Docs/AssetBundleDebugger.md)
|
||||||
5. [着色器](./Docs/ShaderVariantCollector.md)
|
5. [着色器](./Docs/ShaderVariantCollector.md)
|
||||||
5. [常见问题](./Docs/FAQ.md)
|
5. [FAQ](./Docs/FAQ.md)
|
||||||
|
|
||||||
## 代码教程
|
## 代码教程
|
||||||
1. [初始化](./Docs/CodeTutorial1.md)
|
1. [初始化](./Docs/CodeTutorial1.md)
|
||||||
|
|||||||