mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-30 21:48:47 +00:00
Compare commits
27 Commits
2.3.15
...
1918c1f216
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1918c1f216 | ||
|
|
4caf733ac6 | ||
|
|
014b17f5cb | ||
|
|
f3ebda0c04 | ||
|
|
96b33f5816 | ||
|
|
9ad572c7a4 | ||
|
|
5602addaca | ||
|
|
c4ae67aa8e | ||
|
|
bbcc3bf971 | ||
|
|
8b0e75b9b3 | ||
|
|
b1f02049cc | ||
|
|
512886cdf6 | ||
|
|
0c3ccc5c2f | ||
|
|
b0ea03170f | ||
|
|
2c3b890329 | ||
|
|
0f39cb9444 | ||
|
|
8acc16d3f6 | ||
|
|
fd1715a89b | ||
|
|
0934c813d1 | ||
|
|
be71d38cd8 | ||
|
|
4cdfde31da | ||
|
|
0133549ef8 | ||
|
|
81d9eb47c8 | ||
|
|
5fde689f1f | ||
|
|
5d51bfe751 | ||
|
|
ed86edd2b0 | ||
|
|
f627b5b59a |
@@ -2,6 +2,88 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [2.3.16] - 2025-09-17
|
||||
|
||||
### Improvements
|
||||
|
||||
- (#638) 优化了Provider加载机制,引用计数为零时自动挂起!
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#644) [**严重**] 修复了2.3.15版本,资产量巨大的情况下,编辑器下模拟模式初始化耗时很久的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- (#639) 新增了文件系统参数:VIRTUAL_DOWNLOAD_MODE 和 VIRTUAL_DOWNLOAD_SPEED
|
||||
|
||||
编辑器下不需要构建AB,也可以模拟远端资源下载,等同真机运行环境。
|
||||
|
||||
```csharp
|
||||
class DefaultEditorFIleSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 模拟虚拟下载模式
|
||||
/// </summary>
|
||||
public bool VirtualDownloadMode { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 模拟虚拟下载的网速(单位:字节)
|
||||
/// </summary>
|
||||
public int VirtualDownloadSpeed { private set; get; } = 1024;
|
||||
}
|
||||
```
|
||||
|
||||
- (#640) 新增了文件系统参数:VIRTUAL_WEBGL_MODE
|
||||
|
||||
编辑器下不需要构建AB,也可以模拟小游戏开发环境,等同真机运行环境。
|
||||
|
||||
```csharp
|
||||
class DefaultEditorFIleSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 模拟WebGL平台模式
|
||||
/// </summary>
|
||||
public bool VirtualWebGLMode { private set; get; } = false;
|
||||
}
|
||||
```
|
||||
|
||||
- (#642) 新增了文件系统参数:DOWNLOAD_WATCH_DOG_TIME
|
||||
|
||||
监控时间范围内,如果没有接收到任何下载数据,那么直接终止任务!
|
||||
|
||||
```csharp
|
||||
class DefaultCacheFIleSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义参数:下载任务的看门狗机制监控时间
|
||||
/// </summary>
|
||||
public int DownloadWatchDogTime { private set; get; } = int.MaxValue;
|
||||
}
|
||||
```
|
||||
|
||||
### Changed
|
||||
|
||||
- 下载器参数timeout移除。
|
||||
|
||||
可以使用文件系统的看门狗机制代替。
|
||||
|
||||
- (#632) IFilterRule接口变动。
|
||||
|
||||
收集器可以指定搜寻的资源类型,在收集目录资产量巨大的情况下,可以极大加快打包速度!
|
||||
|
||||
```csharp
|
||||
public interface IFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 搜寻的资源类型
|
||||
/// 说明:使用引擎方法搜索获取所有资源列表
|
||||
/// </summary>
|
||||
string FindAssetType { get; }
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
## [2.3.15] - 2025-09-09
|
||||
|
||||
**重要**:升级了资源清单版本,不兼容老版本。建议重新提审安装包。
|
||||
@@ -69,7 +151,9 @@ All notable changes to this package will be documented in this file.
|
||||
|
||||
- (#617) 新增资源收集配置参数:SupportExtensionless
|
||||
|
||||
在不需要模糊加载模式的前提下,开启此选项,可以降低运行时内存大小。
|
||||
在不需要模糊加载模式的前提下,关闭此选项,可以降低运行时内存大小。
|
||||
|
||||
该选项默认开启!
|
||||
|
||||
```csharp
|
||||
public class CollectCommand
|
||||
|
||||
@@ -32,21 +32,14 @@ namespace YooAsset.Editor
|
||||
|
||||
// 开始扫描工作
|
||||
ScanReport report = scanner.RunScanner();
|
||||
|
||||
// 检测报告合法性
|
||||
report.CheckError();
|
||||
|
||||
// 保存扫描结果
|
||||
string saveDirectory = scanner.SaveDirectory;
|
||||
if (string.IsNullOrEmpty(saveDirectory))
|
||||
saveDirectory = "Assets/";
|
||||
string filePath = $"{saveDirectory}/{scanner.ScannerName}_{scanner.ScannerDesc}.json";
|
||||
ScanReportConfig.ExportJsonConfig(filePath, report);
|
||||
return new ScannerResult(filePath, report);
|
||||
// 返回扫描结果
|
||||
return new ScannerResult(report);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ScannerResult(e.StackTrace);
|
||||
return new ScannerResult(e.Message, e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,6 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public class ScannerResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成的报告文件路径
|
||||
/// </summary>
|
||||
public string ReprotFilePath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 报告对象
|
||||
/// </summary>
|
||||
@@ -18,6 +13,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string ErrorInfo { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误堆栈
|
||||
/// </summary>
|
||||
public string ErrorStack { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否成功
|
||||
/// </summary>
|
||||
@@ -33,15 +33,14 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
|
||||
public ScannerResult(string error)
|
||||
public ScannerResult(string error, string stack)
|
||||
{
|
||||
ErrorInfo = error;
|
||||
ErrorStack = stack;
|
||||
}
|
||||
public ScannerResult(string filePath, ScanReport report)
|
||||
public ScannerResult(ScanReport report)
|
||||
{
|
||||
ReprotFilePath = filePath;
|
||||
Report = report;
|
||||
ErrorInfo = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -55,5 +54,19 @@ namespace YooAsset.Editor
|
||||
reproterWindow.ImportSingleReprotFile(Report);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存报告文件
|
||||
/// </summary>
|
||||
public void SaveReportFile(string saveDirectory)
|
||||
{
|
||||
if (Report == null)
|
||||
throw new System.Exception("Scan report is invalid !");
|
||||
|
||||
if (string.IsNullOrEmpty(saveDirectory))
|
||||
saveDirectory = "Assets/";
|
||||
string filePath = $"{saveDirectory}/{Report.ReportName}_{Report.ReportDesc}.json";
|
||||
ScanReportConfig.ExportJsonConfig(filePath, Report);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public static string GetStreamingAssetsRoot()
|
||||
{
|
||||
return YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||
return YooAssetSettingsData.GetYooDefaultBuiltinRoot();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,28 +43,28 @@ namespace YooAsset.Editor
|
||||
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
||||
}
|
||||
|
||||
// EBuildinFileCopyOption
|
||||
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, string buildPipeline)
|
||||
// EBuiltinFileCopyOption
|
||||
public static EBuiltinFileCopyOption GetPackageBuiltinFileCopyOption(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuiltinFileCopyOption)}";
|
||||
return (EBuiltinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuiltinFileCopyOption.None);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyOption(string packageName, string buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
||||
public static void SetPackageBuiltinFileCopyOption(string packageName, string buildPipeline, EBuiltinFileCopyOption builtinFileCopyOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuiltinFileCopyOption)}";
|
||||
EditorPrefs.SetInt(key, (int)builtinFileCopyOption);
|
||||
}
|
||||
|
||||
// BuildFileCopyParams
|
||||
public static string GetPackageBuildinFileCopyParams(string packageName, string buildPipeline)
|
||||
public static string GetPackageBuiltinFileCopyParams(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyParams(string packageName, string buildPipeline, string buildinFileCopyParams)
|
||||
public static void SetPackageBuiltinFileCopyParams(string packageName, string buildPipeline, string builtinFileCopyParams)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
EditorPrefs.SetString(key, buildinFileCopyParams);
|
||||
EditorPrefs.SetString(key, builtinFileCopyParams);
|
||||
}
|
||||
|
||||
// EncyptionServicesClassName
|
||||
|
||||
@@ -17,15 +17,15 @@ namespace YooAsset.Editor
|
||||
{
|
||||
var buildParameters = new EditorSimulateBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuiltinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = EBuildPipeline.EditorSimulateBuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
buildParameters.BuiltinFileCopyOption = EBuiltinFileCopyOption.None;
|
||||
buildParameters.BuiltinFileCopyParams = string.Empty;
|
||||
buildParameters.UseAssetDependencyDB = true;
|
||||
|
||||
var pipeline = new EditorSimulateBuildPipeline();
|
||||
|
||||
@@ -106,7 +106,27 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string[] GetAllPackAssetPaths()
|
||||
{
|
||||
return AllPackAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
|
||||
List<string> results = new List<string>(AllPackAssets.Count);
|
||||
for (int i = 0; i < AllPackAssets.Count; i++)
|
||||
{
|
||||
var packAsset = AllPackAssets[i];
|
||||
results.Add(packAsset.AssetInfo.AssetPath);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的资源可寻址列表
|
||||
/// </summary>
|
||||
public string[] GetAllPackAssetAddress()
|
||||
{
|
||||
List<string> results = new List<string>(AllPackAssets.Count);
|
||||
for (int i = 0; i < AllPackAssets.Count; i++)
|
||||
{
|
||||
var packAsset = AllPackAssets[i];
|
||||
results.Add(packAsset.Address);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -153,13 +173,15 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 创建AssetBundleBuild类
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild(bool replaceAssetPathWithAddress)
|
||||
{
|
||||
// 注意:我们不再支持AssetBundle的变种机制
|
||||
AssetBundleBuild build = new AssetBundleBuild();
|
||||
build.assetBundleName = BundleName;
|
||||
build.assetBundleVariant = string.Empty;
|
||||
build.assetNames = GetAllPackAssetPaths();
|
||||
if (replaceAssetPathWithAddress)
|
||||
build.addressableNames = GetAllPackAssetAddress();
|
||||
return build;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,12 +96,12 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 获取构建管线里需要的数据
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds(bool replaceAssetPathWithAddres)
|
||||
{
|
||||
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
||||
foreach (var bundleInfo in _bundleInfoDic.Values)
|
||||
{
|
||||
builds.Add(bundleInfo.CreatePipelineBuild());
|
||||
builds.Add(bundleInfo.CreatePipelineBuild(replaceAssetPathWithAddres));
|
||||
}
|
||||
return builds.ToArray();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 内置文件的根目录
|
||||
/// </summary>
|
||||
public string BuildinFileRoot;
|
||||
public string BuiltinFileRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线名称
|
||||
@@ -86,12 +86,12 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝选项
|
||||
/// </summary>
|
||||
public EBuildinFileCopyOption BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
public EBuiltinFileCopyOption BuiltinFileCopyOption = EBuiltinFileCopyOption.None;
|
||||
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝参数
|
||||
/// </summary>
|
||||
public string BuildinFileCopyParams;
|
||||
public string BuiltinFileCopyParams;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包加密服务类
|
||||
@@ -111,7 +111,7 @@ namespace YooAsset.Editor
|
||||
private string _pipelineOutputDirectory = string.Empty;
|
||||
private string _packageOutputDirectory = string.Empty;
|
||||
private string _packageRootDirectory = string.Empty;
|
||||
private string _buildinRootDirectory = string.Empty;
|
||||
private string _builtinRootDirectory = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 检测构建参数是否合法
|
||||
@@ -136,9 +136,9 @@ namespace YooAsset.Editor
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildinFileRoot))
|
||||
if (string.IsNullOrEmpty(BuiltinFileRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuiltinFileRootIsNullOrEmpty, "Builtin file root is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildPipeline))
|
||||
@@ -210,13 +210,13 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 获取内置资源的根目录
|
||||
/// </summary>
|
||||
public virtual string GetBuildinRootDirectory()
|
||||
public virtual string GetBuiltinRootDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_buildinRootDirectory))
|
||||
if (string.IsNullOrEmpty(_builtinRootDirectory))
|
||||
{
|
||||
_buildinRootDirectory = $"{BuildinFileRoot}/{PackageName}";
|
||||
_builtinRootDirectory = $"{BuiltinFileRoot}/{PackageName}";
|
||||
}
|
||||
return _buildinRootDirectory;
|
||||
return _builtinRootDirectory;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,9 +55,9 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 获取内置资源的根目录
|
||||
/// </summary>
|
||||
public string GetBuildinRootDirectory()
|
||||
public string GetBuiltinRootDirectory()
|
||||
{
|
||||
return Parameters.GetBuildinRootDirectory();
|
||||
return Parameters.GetBuiltinRootDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,30 +6,30 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuildinFiles
|
||||
public class TaskCopyBuiltinFiles
|
||||
{
|
||||
/// <summary>
|
||||
/// 拷贝首包资源文件
|
||||
/// </summary>
|
||||
internal void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, PackageManifest manifest)
|
||||
internal void CopyBuiltinFilesToStreaming(BuildParametersContext buildParametersContext, PackageManifest manifest)
|
||||
{
|
||||
EBuildinFileCopyOption copyOption = buildParametersContext.Parameters.BuildinFileCopyOption;
|
||||
EBuiltinFileCopyOption copyOption = buildParametersContext.Parameters.BuiltinFileCopyOption;
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||
string builtinRootDirectory = buildParametersContext.GetBuiltinRootDirectory();
|
||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
||||
|
||||
// 清空内置文件的目录
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.ClearAndCopyByTags)
|
||||
if (copyOption == EBuiltinFileCopyOption.ClearAndCopyAll || copyOption == EBuiltinFileCopyOption.ClearAndCopyByTags)
|
||||
{
|
||||
EditorTools.ClearFolder(buildinRootDirectory);
|
||||
EditorTools.ClearFolder(builtinRootDirectory);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildPackageName, buildPackageVersion);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
string destPath = $"{builtinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildPackageName, buildPackageVersion);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
string destPath = $"{builtinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
@@ -45,38 +45,38 @@ namespace YooAsset.Editor
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildPackageName);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
string destPath = $"{builtinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝文件列表(所有文件)
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.OnlyCopyAll)
|
||||
if (copyOption == EBuiltinFileCopyOption.ClearAndCopyAll || copyOption == EBuiltinFileCopyOption.OnlyCopyAll)
|
||||
{
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{builtinRootDirectory}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 拷贝文件列表(带标签的文件)
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyByTags || copyOption == EBuildinFileCopyOption.OnlyCopyByTags)
|
||||
if (copyOption == EBuiltinFileCopyOption.ClearAndCopyByTags || copyOption == EBuiltinFileCopyOption.OnlyCopyByTags)
|
||||
{
|
||||
string[] tags = buildParametersContext.Parameters.BuildinFileCopyParams.Split(';');
|
||||
string[] tags = buildParametersContext.Parameters.BuiltinFileCopyParams.Split(';');
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
if (packageBundle.HasTag(tags) == false)
|
||||
continue;
|
||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{builtinRootDirectory}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
BuildLogger.Log($"Buildin files copy complete: {buildinRootDirectory}");
|
||||
BuildLogger.Log($"Builtin files copy complete: {builtinRootDirectory}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,10 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
internal void CreateCatalogFile(BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||
string builtinRootDirectory = buildParametersContext.GetBuiltinRootDirectory();
|
||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||
var manifestServices = buildParametersContext.Parameters.ManifestRestoreServices;
|
||||
CatalogTools.CreateCatalogFile(manifestServices, buildPackageName, buildinRootDirectory);
|
||||
CatalogTools.CreateCatalogFile(manifestServices, buildPackageName, builtinRootDirectory);
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 创建补丁清单文件到输出目录
|
||||
/// </summary>
|
||||
protected void CreateManifestFile(bool processBundleDepends, bool processBundleTags, BuildContext context)
|
||||
protected void CreateManifestFile(bool processBundleDepends, bool processBundleTags, bool replaceAssetPathWithAddress, BuildContext context)
|
||||
{
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
@@ -36,6 +36,7 @@ namespace YooAsset.Editor
|
||||
manifest.SupportExtensionless = buildMapContext.Command.SupportExtensionless;
|
||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||
manifest.ReplaceAssetPathWithAddress = replaceAssetPathWithAddress;
|
||||
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
||||
manifest.BuildBundleType = buildParameters.BuildBundleType;
|
||||
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
||||
@@ -58,7 +59,13 @@ namespace YooAsset.Editor
|
||||
|
||||
// 4. 处理内置资源包
|
||||
if (processBundleDepends)
|
||||
{
|
||||
// 注意:初始化资源清单建立引用关系
|
||||
manifest.Initialize();
|
||||
|
||||
ProcessBuiltinBundleDependency(context, manifest);
|
||||
}
|
||||
|
||||
|
||||
// 创建资源清单文本文件
|
||||
{
|
||||
@@ -302,9 +309,6 @@ namespace YooAsset.Editor
|
||||
#region YOOASSET_LEGACY_DEPENDENCY
|
||||
private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
|
||||
{
|
||||
// 注意:初始化资源清单建立引用关系
|
||||
ManifestTools.InitManifest(manifest);
|
||||
|
||||
// 注意:如果是可编程构建管线,需要补充内置资源包
|
||||
// 注意:该步骤依赖前面的操作!
|
||||
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
||||
buildReport.Summary.ReplaceAssetPathWithAddress = builtinBuildParameters.ReplaceAssetPathWithAddress;
|
||||
}
|
||||
else if (buildParameters is ScriptableBuildParameters)
|
||||
{
|
||||
@@ -61,6 +62,7 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
||||
buildReport.Summary.ReplaceAssetPathWithAddress = scriptableBuildParameters.ReplaceAssetPathWithAddress;
|
||||
buildReport.Summary.WriteLinkXML = scriptableBuildParameters.WriteLinkXML;
|
||||
buildReport.Summary.CacheServerHost = scriptableBuildParameters.CacheServerHost;
|
||||
buildReport.Summary.CacheServerPort = scriptableBuildParameters.CacheServerPort;
|
||||
|
||||
@@ -23,7 +23,8 @@ namespace YooAsset.Editor
|
||||
// 开始构建
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||
var bundleBuilds = buildMapContext.GetPipelineBuilds(builtinBuildParameters.ReplaceAssetPathWithAddress);
|
||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, bundleBuilds, buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||
if (unityManifest == null)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
||||
|
||||
@@ -6,15 +6,15 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
|
||||
public class TaskCopyBuiltinFiles_BBP : TaskCopyBuiltinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
if (buildParametersContext.Parameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
CopyBuiltinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
if (buildParametersContext.Parameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
{
|
||||
CreateCatalogFile(buildParametersContext);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,10 @@ namespace YooAsset.Editor
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(true, true, context);
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||
bool replaceAssetPathWithAddress = builtinBuildParameters.ReplaceAssetPathWithAddress;
|
||||
CreateManifestFile(true, true, replaceAssetPathWithAddress, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
|
||||
@@ -27,6 +27,12 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
|
||||
/// <summary>
|
||||
/// 使用可寻址地址代替资源路径
|
||||
/// 说明:开启此项可以节省运行时清单占用的内存!
|
||||
/// </summary>
|
||||
public bool ReplaceAssetPathWithAddress = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置构建管线的构建选项
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace YooAsset.Editor
|
||||
new TaskCreateManifest_BBP(),
|
||||
new TaskCreateReport_BBP(),
|
||||
new TaskCreatePackage_BBP(),
|
||||
new TaskCopyBuildinFiles_BBP(),
|
||||
new TaskCopyBuiltinFiles_BBP(),
|
||||
new TaskCreateCatalog_BBP()
|
||||
};
|
||||
return pipeline;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(false, false, context);
|
||||
CreateManifestFile(false, false, false, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
|
||||
@@ -6,16 +6,16 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask
|
||||
public class TaskCopyBuiltinFiles_RFBP : TaskCopyBuiltinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
if (buildParameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
CopyBuiltinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
if (buildParametersContext.Parameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
{
|
||||
CreateCatalogFile(buildParametersContext);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(false, true, context);
|
||||
CreateManifestFile(false, true, false, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace YooAsset.Editor
|
||||
new TaskCreateManifest_RFBP(),
|
||||
new TaskCreateReport_RFBP(),
|
||||
new TaskCreatePackage_RFBP(),
|
||||
new TaskCopyBuildinFiles_RFBP(),
|
||||
new TaskCopyBuiltinFiles_RFBP(),
|
||||
new TaskCreateCatalog_RFBP()
|
||||
};
|
||||
return pipeline;
|
||||
|
||||
@@ -24,7 +24,8 @@ namespace YooAsset.Editor
|
||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
|
||||
// 构建内容
|
||||
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
|
||||
var bundleBuilds = buildMapContext.GetPipelineBuilds(scriptableBuildParameters.ReplaceAssetPathWithAddress);
|
||||
var buildContent = new BundleBuildContent(bundleBuilds);
|
||||
|
||||
// 开始构建
|
||||
IBundleBuildResults buildResults;
|
||||
|
||||
@@ -6,15 +6,15 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuildinFiles_SBP : TaskCopyBuildinFiles, IBuildTask
|
||||
public class TaskCopyBuiltinFiles_SBP : TaskCopyBuiltinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
if (buildParametersContext.Parameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
CopyBuiltinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
if (buildParametersContext.Parameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
{
|
||||
CreateCatalogFile(buildParametersContext);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@ namespace YooAsset.Editor
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(true, true, context);
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
bool replaceAssetPathWithAddress = scriptableBuildParameters.ReplaceAssetPathWithAddress;
|
||||
CreateManifestFile(true, true, replaceAssetPathWithAddress, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
|
||||
@@ -29,6 +29,12 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
|
||||
/// <summary>
|
||||
/// 使用可寻址地址代替资源路径
|
||||
/// 说明:开启此项可以节省运行时清单占用的内存!
|
||||
/// </summary>
|
||||
public bool ReplaceAssetPathWithAddress = false;
|
||||
|
||||
/// <summary>
|
||||
/// 自动建立资源对象对图集的依赖关系
|
||||
/// </summary>
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace YooAsset.Editor
|
||||
new TaskCreateManifest_SBP(),
|
||||
new TaskCreateReport_SBP(),
|
||||
new TaskCreatePackage_SBP(),
|
||||
new TaskCopyBuildinFiles_SBP(),
|
||||
new TaskCopyBuiltinFiles_SBP(),
|
||||
new TaskCreateCatalog_SBP()
|
||||
};
|
||||
return pipeline;
|
||||
|
||||
@@ -21,6 +21,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string ErrorInfo;
|
||||
|
||||
/// <summary>
|
||||
/// 构建失败的堆栈
|
||||
/// </summary>
|
||||
public string ErrorStack;
|
||||
|
||||
/// <summary>
|
||||
/// 输出的补丁包目录
|
||||
/// </summary>
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace YooAsset.Editor
|
||||
EditorTools.ClearProgressBar();
|
||||
buildResult.FailedTask = task.GetType().Name;
|
||||
buildResult.ErrorInfo = e.ToString();
|
||||
buildResult.ErrorStack = e.StackTrace;
|
||||
buildResult.Success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
||||
PackageNameIsNullOrEmpty = 111,
|
||||
PackageVersionIsNullOrEmpty = 112,
|
||||
BuildOutputRootIsNullOrEmpty = 113,
|
||||
BuildinFileRootIsNullOrEmpty = 114,
|
||||
BuiltinFileRootIsNullOrEmpty = 114,
|
||||
PackageOutputDirectoryExists = 115,
|
||||
BuildPipelineIsNullOrEmpty = 116,
|
||||
BuildBundleTypeIsUnknown = 117,
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 首包资源文件的拷贝方式
|
||||
/// </summary>
|
||||
public enum EBuildinFileCopyOption
|
||||
public enum EBuiltinFileCopyOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 不拷贝任何文件
|
||||
@@ -127,35 +127,35 @@ namespace YooAsset.Editor
|
||||
});
|
||||
UIElementsTools.SetElementLabelMinWidth(enumField, LabelMinWidth);
|
||||
}
|
||||
protected void SetCopyBuildinFileOptionField(EnumField enumField, TextField tagField)
|
||||
protected void SetCopyBuiltinFileOptionField(EnumField enumField, TextField tagField)
|
||||
{
|
||||
// 首包文件拷贝选项
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
enumField.Init(buildinFileCopyOption);
|
||||
enumField.SetValueWithoutNotify(buildinFileCopyOption);
|
||||
var builtinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
enumField.Init(builtinFileCopyOption);
|
||||
enumField.SetValueWithoutNotify(builtinFileCopyOption);
|
||||
enumField.style.width = StyleWidth;
|
||||
enumField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(PackageName, PipelineName, (EBuildinFileCopyOption)enumField.value);
|
||||
AssetBundleBuilderSetting.SetPackageBuiltinFileCopyOption(PackageName, PipelineName, (EBuiltinFileCopyOption)enumField.value);
|
||||
|
||||
// 设置内置资源标签显隐
|
||||
SetCopyBuildinFileTagsVisible(tagField);
|
||||
SetCopyBuiltinFileTagsVisible(tagField);
|
||||
});
|
||||
UIElementsTools.SetElementLabelMinWidth(enumField, LabelMinWidth);
|
||||
}
|
||||
protected void SetCopyBuildinFileTagsVisible(TextField tagField)
|
||||
protected void SetCopyBuiltinFileTagsVisible(TextField tagField)
|
||||
{
|
||||
var option = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
tagField.visible = option == EBuildinFileCopyOption.ClearAndCopyByTags || option == EBuildinFileCopyOption.OnlyCopyByTags;
|
||||
var option = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
tagField.visible = option == EBuiltinFileCopyOption.ClearAndCopyByTags || option == EBuiltinFileCopyOption.OnlyCopyByTags;
|
||||
}
|
||||
protected void SetCopyBuildinFileTagsField(TextField textField)
|
||||
protected void SetCopyBuiltinFileTagsField(TextField textField)
|
||||
{
|
||||
// 首包文件拷贝参数
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
textField.SetValueWithoutNotify(buildinFileCopyParams);
|
||||
var builtinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyParams(PackageName, PipelineName);
|
||||
textField.SetValueWithoutNotify(builtinFileCopyParams);
|
||||
textField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(PackageName, PipelineName, textField.value);
|
||||
AssetBundleBuilderSetting.SetPackageBuiltinFileCopyParams(PackageName, PipelineName, textField.value);
|
||||
});
|
||||
UIElementsTools.SetElementLabelMinWidth(textField, LabelMinWidth);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace YooAsset.Editor
|
||||
protected PopupField<Type> _manifestRestoreServicesField;
|
||||
protected EnumField _compressionField;
|
||||
protected EnumField _outputNameStyleField;
|
||||
protected EnumField _copyBuildinFileOptionField;
|
||||
protected TextField _copyBuildinFileTagsField;
|
||||
protected EnumField _copyBuiltinFileOptionField;
|
||||
protected TextField _copyBuiltinFileTagsField;
|
||||
protected Toggle _clearBuildCacheToggle;
|
||||
protected Toggle _useAssetDependencyDBToggle;
|
||||
|
||||
@@ -60,13 +60,13 @@ namespace YooAsset.Editor
|
||||
SetOutputNameStyleField(_outputNameStyleField);
|
||||
|
||||
// 首包文件拷贝参数
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
SetCopyBuildinFileTagsField(_copyBuildinFileTagsField);
|
||||
SetCopyBuildinFileTagsVisible(_copyBuildinFileTagsField);
|
||||
_copyBuiltinFileTagsField = Root.Q<TextField>("CopyBuiltinFileParam");
|
||||
SetCopyBuiltinFileTagsField(_copyBuiltinFileTagsField);
|
||||
SetCopyBuiltinFileTagsVisible(_copyBuiltinFileTagsField);
|
||||
|
||||
// 首包文件拷贝选项
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
SetCopyBuildinFileOptionField(_copyBuildinFileOptionField, _copyBuildinFileTagsField);
|
||||
_copyBuiltinFileOptionField = Root.Q<EnumField>("CopyBuiltinFileOption");
|
||||
SetCopyBuiltinFileOptionField(_copyBuiltinFileOptionField, _copyBuiltinFileTagsField);
|
||||
|
||||
// 清理构建缓存
|
||||
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
@@ -99,15 +99,15 @@ namespace YooAsset.Editor
|
||||
protected virtual void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
var builtinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
var builtinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyParams(PackageName, PipelineName);
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, PipelineName);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, PipelineName);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, PipelineName);
|
||||
|
||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuiltinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
@@ -116,8 +116,8 @@ namespace YooAsset.Editor
|
||||
buildParameters.EnableSharePackRule = true;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.BuiltinFileCopyOption = builtinFileCopyOption;
|
||||
buildParameters.BuiltinFileCopyParams = builtinFileCopyParams;
|
||||
buildParameters.CompressOption = compressOption;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
<ui:VisualElement name="PopupContainer" style="flex-grow: 1;" />
|
||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Param" name="CopyBuildinFileParam" />
|
||||
<uie:EnumField label="Copy Builtin File Option" value="Center" name="CopyBuiltinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Builtin File Param" name="CopyBuiltinFileParam" />
|
||||
<ui:VisualElement name="ExtensionContainer" />
|
||||
<ui:Button text="Click Build" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||
</ui:VisualElement>
|
||||
|
||||
@@ -59,12 +59,12 @@ namespace YooAsset.Editor
|
||||
protected virtual void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
var builtinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
var builtinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyParams(PackageName, PipelineName);
|
||||
|
||||
EditorSimulateBuildParameters buildParameters = new EditorSimulateBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuiltinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
@@ -72,8 +72,8 @@ namespace YooAsset.Editor
|
||||
buildParameters.PackageVersion = _buildVersionField.value;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.BuiltinFileCopyOption = builtinFileCopyOption;
|
||||
buildParameters.BuiltinFileCopyParams = builtinFileCopyParams;
|
||||
|
||||
EditorSimulateBuildPipeline pipeline = new EditorSimulateBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace YooAsset.Editor
|
||||
protected PopupField<Type> _manifestProcessServicesField;
|
||||
protected PopupField<Type> _manifestRestoreServicesField;
|
||||
protected EnumField _outputNameStyleField;
|
||||
protected EnumField _copyBuildinFileOptionField;
|
||||
protected TextField _copyBuildinFileTagsField;
|
||||
protected EnumField _copyBuiltinFileOptionField;
|
||||
protected TextField _copyBuiltinFileTagsField;
|
||||
protected Toggle _clearBuildCacheToggle;
|
||||
protected Toggle _useAssetDependencyDBToggle;
|
||||
|
||||
@@ -55,13 +55,13 @@ namespace YooAsset.Editor
|
||||
SetOutputNameStyleField(_outputNameStyleField);
|
||||
|
||||
// 首包文件拷贝参数
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
SetCopyBuildinFileTagsField(_copyBuildinFileTagsField);
|
||||
SetCopyBuildinFileTagsVisible(_copyBuildinFileTagsField);
|
||||
_copyBuiltinFileTagsField = Root.Q<TextField>("CopyBuiltinFileParam");
|
||||
SetCopyBuiltinFileTagsField(_copyBuiltinFileTagsField);
|
||||
SetCopyBuiltinFileTagsVisible(_copyBuiltinFileTagsField);
|
||||
|
||||
// 首包文件拷贝选项
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
SetCopyBuildinFileOptionField(_copyBuildinFileOptionField, _copyBuildinFileTagsField);
|
||||
_copyBuiltinFileOptionField = Root.Q<EnumField>("CopyBuiltinFileOption");
|
||||
SetCopyBuiltinFileOptionField(_copyBuiltinFileOptionField, _copyBuiltinFileTagsField);
|
||||
|
||||
// 清理构建缓存
|
||||
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
@@ -94,14 +94,14 @@ namespace YooAsset.Editor
|
||||
protected virtual void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
var builtinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
var builtinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyParams(PackageName, PipelineName);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, PipelineName);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, PipelineName);
|
||||
|
||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuiltinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.RawBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
@@ -109,8 +109,8 @@ namespace YooAsset.Editor
|
||||
buildParameters.PackageVersion = _buildVersionField.value;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.BuiltinFileCopyOption = builtinFileCopyOption;
|
||||
buildParameters.BuiltinFileCopyParams = builtinFileCopyParams;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<ui:Toggle label="Use Asset Depend DB" name="UseAssetDependency" />
|
||||
<ui:VisualElement name="PopupContainer" style="flex-grow: 1;" />
|
||||
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Param" name="CopyBuildinFileParam" />
|
||||
<uie:EnumField label="Copy Builtin File Option" value="Center" name="CopyBuiltinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Builtin File Param" name="CopyBuiltinFileParam" />
|
||||
<ui:VisualElement name="ExtensionContainer" />
|
||||
<ui:Button text="Click Build" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||
</ui:VisualElement>
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace YooAsset.Editor
|
||||
protected PopupField<Type> _manifestRestoreServicesField;
|
||||
protected EnumField _compressionField;
|
||||
protected EnumField _outputNameStyleField;
|
||||
protected EnumField _copyBuildinFileOptionField;
|
||||
protected TextField _copyBuildinFileTagsField;
|
||||
protected EnumField _copyBuiltinFileOptionField;
|
||||
protected TextField _copyBuiltinFileTagsField;
|
||||
protected Toggle _clearBuildCacheToggle;
|
||||
protected Toggle _useAssetDependencyDBToggle;
|
||||
|
||||
@@ -60,13 +60,13 @@ namespace YooAsset.Editor
|
||||
SetOutputNameStyleField(_outputNameStyleField);
|
||||
|
||||
// 首包文件拷贝参数
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
SetCopyBuildinFileTagsField(_copyBuildinFileTagsField);
|
||||
SetCopyBuildinFileTagsVisible(_copyBuildinFileTagsField);
|
||||
_copyBuiltinFileTagsField = Root.Q<TextField>("CopyBuiltinFileParam");
|
||||
SetCopyBuiltinFileTagsField(_copyBuiltinFileTagsField);
|
||||
SetCopyBuiltinFileTagsVisible(_copyBuiltinFileTagsField);
|
||||
|
||||
// 首包文件拷贝选项
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
SetCopyBuildinFileOptionField(_copyBuildinFileOptionField, _copyBuildinFileTagsField);
|
||||
_copyBuiltinFileOptionField = Root.Q<EnumField>("CopyBuiltinFileOption");
|
||||
SetCopyBuiltinFileOptionField(_copyBuiltinFileOptionField, _copyBuiltinFileTagsField);
|
||||
|
||||
// 清理构建缓存
|
||||
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
@@ -99,15 +99,15 @@ namespace YooAsset.Editor
|
||||
protected virtual void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
var builtinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
var builtinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyParams(PackageName, PipelineName);
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, PipelineName);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, PipelineName);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, PipelineName);
|
||||
|
||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuiltinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
@@ -116,8 +116,8 @@ namespace YooAsset.Editor
|
||||
buildParameters.EnableSharePackRule = true;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.BuiltinFileCopyOption = builtinFileCopyOption;
|
||||
buildParameters.BuiltinFileCopyParams = builtinFileCopyParams;
|
||||
buildParameters.CompressOption = compressOption;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
<ui:VisualElement name="PopupContainer" style="flex-grow: 1;" />
|
||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Param" name="CopyBuildinFileParam" />
|
||||
<uie:EnumField label="Copy Builtin File Option" value="Center" name="CopyBuiltinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Builtin File Param" name="CopyBuiltinFileParam" />
|
||||
<ui:VisualElement name="ExtensionContainer" />
|
||||
<ui:Button text="Click Build" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||
</ui:VisualElement>
|
||||
|
||||
@@ -139,14 +139,30 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
||||
{
|
||||
bool ignoreStaticCollector = command.IsFlagSet(ECollectFlags.IgnoreStaticCollector);
|
||||
if (ignoreStaticCollector)
|
||||
{
|
||||
if (CollectorType == ECollectorType.StaticAssetCollector)
|
||||
return new List<CollectAssetInfo>();
|
||||
}
|
||||
|
||||
bool ignoreDependCollector = command.IsFlagSet(ECollectFlags.IgnoreDependCollector);
|
||||
if (ignoreDependCollector)
|
||||
{
|
||||
if (CollectorType == ECollectorType.DependAssetCollector)
|
||||
return new List<CollectAssetInfo>();
|
||||
}
|
||||
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
||||
|
||||
// 收集打包资源路径
|
||||
List<string> findAssets = new List<string>();
|
||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||
{
|
||||
string collectDirectory = CollectPath;
|
||||
string[] findResult = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||
string findAssetType = filterRuleInstance.FindAssetType;
|
||||
string searchFolder = CollectPath;
|
||||
string[] findResult = EditorTools.FindAssets(findAssetType, searchFolder);
|
||||
findAssets.AddRange(findResult);
|
||||
}
|
||||
else
|
||||
@@ -262,8 +278,8 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
||||
{
|
||||
// 注意:模拟构建模式下不需要收集依赖资源
|
||||
if (command.SimulateBuild)
|
||||
bool ignoreGetDependencies = command.IsFlagSet(ECollectFlags.IgnoreGetDependencies);
|
||||
if (ignoreGetDependencies)
|
||||
return new List<AssetInfo>();
|
||||
|
||||
string[] depends = command.AssetDependency.GetDependencies(mainAssetPath, true);
|
||||
|
||||
@@ -1028,7 +1028,7 @@ namespace YooAsset.Editor
|
||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
||||
string packageName = _packageNameTxt.value;
|
||||
var command = new CollectCommand(packageName, ignoreRule);
|
||||
command.SimulateBuild = true;
|
||||
command.SetFlag(ECollectFlags.IgnoreGetDependencies, true);
|
||||
command.UniqueBundleName = _uniqueBundleNameToogle.value;
|
||||
command.EnableAddressable = _enableAddressableToogle.value;
|
||||
command.SupportExtensionless = _supportExtensionlessToogle.value;
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public enum ECollectFlags
|
||||
{
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 不收集依赖资源
|
||||
/// </summary>
|
||||
IgnoreGetDependencies = 1 << 0,
|
||||
|
||||
/// <summary>
|
||||
/// 忽略静态收集器
|
||||
/// </summary>
|
||||
IgnoreStaticCollector = 1 << 1,
|
||||
|
||||
/// <summary>
|
||||
/// 忽略依赖收集器
|
||||
/// </summary>
|
||||
IgnoreDependCollector = 1 << 2,
|
||||
}
|
||||
|
||||
public class CollectCommand
|
||||
{
|
||||
/// <summary>
|
||||
@@ -17,7 +37,20 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 模拟构建模式
|
||||
/// </summary>
|
||||
public bool SimulateBuild { set; get; }
|
||||
public bool SimulateBuild
|
||||
{
|
||||
set
|
||||
{
|
||||
SetFlag(ECollectFlags.IgnoreGetDependencies, value);
|
||||
SetFlag(ECollectFlags.IgnoreStaticCollector, value);
|
||||
SetFlag(ECollectFlags.IgnoreDependCollector, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口收集模式
|
||||
/// </summary>
|
||||
public int CollectFlags { set; get; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
@@ -70,5 +103,24 @@ namespace YooAsset.Editor
|
||||
PackageName = packageName;
|
||||
IgnoreRule = ignoreRule;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置标记位
|
||||
/// </summary>
|
||||
public void SetFlag(ECollectFlags flag, bool isOn)
|
||||
{
|
||||
if (isOn)
|
||||
CollectFlags |= (int)flag; // 开启指定标志位
|
||||
else
|
||||
CollectFlags &= ~(int)flag; // 关闭指定标志位
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询标记位
|
||||
/// </summary>
|
||||
public bool IsFlagSet(ECollectFlags flag)
|
||||
{
|
||||
return (CollectFlags & (int)flag) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,13 @@ namespace YooAsset.Editor
|
||||
public interface IFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否为收集资源
|
||||
/// 搜寻的资源类型
|
||||
/// 说明:使用引擎方法搜索获取所有资源列表
|
||||
/// </summary>
|
||||
string FindAssetType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证搜寻的资源是否为收集资源
|
||||
/// </summary>
|
||||
/// <returns>如果收集该资源返回TRUE</returns>
|
||||
bool IsCollectAsset(FilterRuleData data);
|
||||
|
||||
@@ -9,6 +9,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集所有资源")]
|
||||
public class CollectAll : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.All.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return true;
|
||||
@@ -18,6 +23,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集场景")]
|
||||
public class CollectScene : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Scene.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
string extension = Path.GetExtension(data.AssetPath);
|
||||
@@ -28,6 +38,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集预制体")]
|
||||
public class CollectPrefab : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Prefab.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".prefab";
|
||||
@@ -37,6 +52,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集精灵类型的纹理")]
|
||||
public class CollectSprite : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Sprite.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
|
||||
@@ -58,6 +78,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集着色器")]
|
||||
public class CollectShader : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Shader.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".shader";
|
||||
@@ -67,6 +92,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集着色器变种集合")]
|
||||
public class CollectShaderVariants : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.All.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".shadervariants";
|
||||
|
||||
@@ -81,6 +81,7 @@ namespace YooAsset.Editor
|
||||
public ECompressOption CompressOption;
|
||||
public bool DisableWriteTypeTree;
|
||||
public bool IgnoreTypeTreeChanges;
|
||||
public bool ReplaceAssetPathWithAddress;
|
||||
public bool WriteLinkXML = true;
|
||||
public string CacheServerHost;
|
||||
public int CacheServerPort;
|
||||
|
||||
@@ -74,6 +74,7 @@ namespace YooAsset.Editor
|
||||
BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}");
|
||||
BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}");
|
||||
BindListViewItem("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}");
|
||||
BindListViewItem("ReplaceAssetPathWithAddress", $"{buildReport.Summary.ReplaceAssetPathWithAddress}");
|
||||
BindListViewItem(string.Empty, string.Empty);
|
||||
|
||||
BindListViewHeader("Build Results");
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace YooAsset.Editor
|
||||
Shader,
|
||||
Sprite,
|
||||
Texture,
|
||||
RenderTexture,
|
||||
VideoClip,
|
||||
}
|
||||
|
||||
|
||||
@@ -169,6 +169,28 @@ namespace YooAsset.Editor
|
||||
/// <param name="searchInFolders">指定搜索的文件夹列表</param>
|
||||
/// <returns>返回搜集到的资源路径列表</returns>
|
||||
public static string[] FindAssets(EAssetSearchType searchType, string[] searchInFolders)
|
||||
{
|
||||
return FindAssets(searchType.ToString(), searchInFolders);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜集资源
|
||||
/// </summary>
|
||||
/// <param name="searchType">搜集的资源类型</param>
|
||||
/// <param name="searchInFolder">指定搜索的文件夹</param>
|
||||
/// <returns>返回搜集到的资源路径列表</returns>
|
||||
public static string[] FindAssets(EAssetSearchType searchType, string searchInFolder)
|
||||
{
|
||||
return FindAssets(searchType.ToString(), new string[] { searchInFolder });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜集资源
|
||||
/// </summary>
|
||||
/// <param name="searchType">搜集的资源类型</param>
|
||||
/// <param name="searchInFolders">指定搜索的文件夹列表</param>
|
||||
/// <returns>返回搜集到的资源路径列表</returns>
|
||||
public static string[] FindAssets(string searchType, string[] searchInFolders)
|
||||
{
|
||||
// 注意:AssetDatabase.FindAssets()不支持末尾带分隔符的文件夹路径
|
||||
for (int i = 0; i < searchInFolders.Length; i++)
|
||||
@@ -179,7 +201,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 注意:获取指定目录下的所有资源对象(包括子文件夹)
|
||||
string[] guids;
|
||||
if (searchType == EAssetSearchType.All)
|
||||
if (string.IsNullOrEmpty(searchType) || searchType == EAssetSearchType.All.ToString())
|
||||
guids = AssetDatabase.FindAssets(string.Empty, searchInFolders);
|
||||
else
|
||||
guids = AssetDatabase.FindAssets($"t:{searchType}", searchInFolders);
|
||||
@@ -206,7 +228,7 @@ namespace YooAsset.Editor
|
||||
/// <param name="searchType">搜集的资源类型</param>
|
||||
/// <param name="searchInFolder">指定搜索的文件夹</param>
|
||||
/// <returns>返回搜集到的资源路径列表</returns>
|
||||
public static string[] FindAssets(EAssetSearchType searchType, string searchInFolder)
|
||||
public static string[] FindAssets(string searchType, string searchInFolder)
|
||||
{
|
||||
return FindAssets(searchType, new string[] { searchInFolder });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class UnityVirtualBundleRequestOperation : UnityWebRequestOperation
|
||||
{
|
||||
protected enum ESteps
|
||||
{
|
||||
None,
|
||||
Download,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly PackageBundle _bundle;
|
||||
private readonly int _downloadSpeed;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal UnityVirtualBundleRequestOperation(PackageBundle packageBundle, int downloadSpeed, string url) : base(url)
|
||||
{
|
||||
_bundle = packageBundle;
|
||||
_downloadSpeed = downloadSpeed;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.Download;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.Download)
|
||||
{
|
||||
// 模拟下载进度
|
||||
float progress = 0;
|
||||
if (DownloadedBytes > 0)
|
||||
progress = DownloadedBytes / _bundle.FileSize;
|
||||
long downloadBytes = (long)((double)_downloadSpeed * Time.deltaTime);
|
||||
|
||||
Progress = progress;
|
||||
DownloadProgress = progress;
|
||||
DownloadedBytes += downloadBytes;
|
||||
if (DownloadedBytes < _bundle.FileSize)
|
||||
return;
|
||||
|
||||
Progress = 1f;
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
if (_steps != ESteps.Done)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Try load bundle {_bundle.BundleName} from remote !";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e71e850eded0da43906cb4f7cb75629
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,89 +0,0 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DBFSLoadPackageManifestOperation : FSLoadPackageManifestOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestBuildinPackageHash,
|
||||
LoadBuildinPackageManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private RequestBuildinPackageHashOperation _requestBuildinPackageHashOp;
|
||||
private LoadBuildinPackageManifestOperation _loadBuildinPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
public DBFSLoadPackageManifestOperation(DefaultBuildinFileSystem fileSystem, string packageVersion)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestBuildinPackageHash;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestBuildinPackageHash)
|
||||
{
|
||||
if (_requestBuildinPackageHashOp == null)
|
||||
{
|
||||
_requestBuildinPackageHashOp = new RequestBuildinPackageHashOperation(_fileSystem, _packageVersion);
|
||||
_requestBuildinPackageHashOp.StartOperation();
|
||||
AddChildOperation(_requestBuildinPackageHashOp);
|
||||
}
|
||||
|
||||
_requestBuildinPackageHashOp.UpdateOperation();
|
||||
if (_requestBuildinPackageHashOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_requestBuildinPackageHashOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadBuildinPackageManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _requestBuildinPackageHashOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadBuildinPackageManifest)
|
||||
{
|
||||
if (_loadBuildinPackageManifestOp == null)
|
||||
{
|
||||
string packageHash = _requestBuildinPackageHashOp.PackageHash;
|
||||
_loadBuildinPackageManifestOp = new LoadBuildinPackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||
_loadBuildinPackageManifestOp.StartOperation();
|
||||
AddChildOperation(_loadBuildinPackageManifestOp);
|
||||
}
|
||||
|
||||
_loadBuildinPackageManifestOp.UpdateOperation();
|
||||
if (_loadBuildinPackageManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadBuildinPackageManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Manifest = _loadBuildinPackageManifestOp.Manifest;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadBuildinPackageManifestOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,10 +53,10 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 创建内置清单实例
|
||||
var buildinFileCatalog = new DefaultBuildinFileCatalog();
|
||||
buildinFileCatalog.FileVersion = CatalogDefine.FileVersion;
|
||||
buildinFileCatalog.PackageName = packageName;
|
||||
buildinFileCatalog.PackageVersion = packageVersion;
|
||||
var builtinFileCatalog = new DefaultBuiltinFileCatalog();
|
||||
builtinFileCatalog.FileVersion = CatalogDefine.FileVersion;
|
||||
builtinFileCatalog.PackageName = packageName;
|
||||
builtinFileCatalog.PackageVersion = packageVersion;
|
||||
|
||||
// 创建白名单查询集合
|
||||
HashSet<string> whiteFileList = new HashSet<string>
|
||||
@@ -68,8 +68,8 @@ namespace YooAsset
|
||||
$"{packageName}_{packageVersion}.hash",
|
||||
$"{packageName}_{packageVersion}.json",
|
||||
$"{packageName}_{packageVersion}.report",
|
||||
DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName,
|
||||
DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName
|
||||
DefaultBuiltinFileSystemDefine.BuiltinCatalogJsonFileName,
|
||||
DefaultBuiltinFileSystemDefine.BuiltinCatalogBinaryFileName
|
||||
};
|
||||
|
||||
// 记录所有内置资源文件
|
||||
@@ -86,10 +86,10 @@ namespace YooAsset
|
||||
string fileName = fileInfo.Name;
|
||||
if (fileMapping.TryGetValue(fileName, out string bundleGUID))
|
||||
{
|
||||
var wrapper = new DefaultBuildinFileCatalog.FileWrapper();
|
||||
var wrapper = new DefaultBuiltinFileCatalog.FileWrapper();
|
||||
wrapper.BundleGUID = bundleGUID;
|
||||
wrapper.FileName = fileName;
|
||||
buildinFileCatalog.Wrappers.Add(wrapper);
|
||||
builtinFileCatalog.Wrappers.Add(wrapper);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -98,16 +98,16 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 创建输出文件
|
||||
string jsonFilePath = $"{packageDirectory}/{DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName}";
|
||||
string jsonFilePath = $"{packageDirectory}/{DefaultBuiltinFileSystemDefine.BuiltinCatalogJsonFileName}";
|
||||
if (File.Exists(jsonFilePath))
|
||||
File.Delete(jsonFilePath);
|
||||
SerializeToJson(jsonFilePath, buildinFileCatalog);
|
||||
SerializeToJson(jsonFilePath, builtinFileCatalog);
|
||||
|
||||
// 创建输出文件
|
||||
string binaryFilePath = $"{packageDirectory}/{DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName}";
|
||||
string binaryFilePath = $"{packageDirectory}/{DefaultBuiltinFileSystemDefine.BuiltinCatalogBinaryFileName}";
|
||||
if (File.Exists(binaryFilePath))
|
||||
File.Delete(binaryFilePath);
|
||||
SerializeToBinary(binaryFilePath, buildinFileCatalog);
|
||||
SerializeToBinary(binaryFilePath, builtinFileCatalog);
|
||||
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
Debug.Log($"Succeed to save catalog file : {binaryFilePath}");
|
||||
@@ -118,7 +118,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 序列化(JSON文件)
|
||||
/// </summary>
|
||||
public static void SerializeToJson(string savePath, DefaultBuildinFileCatalog catalog)
|
||||
public static void SerializeToJson(string savePath, DefaultBuiltinFileCatalog catalog)
|
||||
{
|
||||
string json = JsonUtility.ToJson(catalog, true);
|
||||
FileUtility.WriteAllText(savePath, json);
|
||||
@@ -127,15 +127,15 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 反序列化(JSON文件)
|
||||
/// </summary>
|
||||
public static DefaultBuildinFileCatalog DeserializeFromJson(string jsonContent)
|
||||
public static DefaultBuiltinFileCatalog DeserializeFromJson(string jsonContent)
|
||||
{
|
||||
return JsonUtility.FromJson<DefaultBuildinFileCatalog>(jsonContent);
|
||||
return JsonUtility.FromJson<DefaultBuiltinFileCatalog>(jsonContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化(二进制文件)
|
||||
/// </summary>
|
||||
public static void SerializeToBinary(string savePath, DefaultBuildinFileCatalog catalog)
|
||||
public static void SerializeToBinary(string savePath, DefaultBuiltinFileCatalog catalog)
|
||||
{
|
||||
using (FileStream fs = new FileStream(savePath, FileMode.Create))
|
||||
{
|
||||
@@ -170,7 +170,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 反序列化(二进制文件)
|
||||
/// </summary>
|
||||
public static DefaultBuildinFileCatalog DeserializeFromBinary(byte[] binaryData)
|
||||
public static DefaultBuiltinFileCatalog DeserializeFromBinary(byte[] binaryData)
|
||||
{
|
||||
// 创建缓存器
|
||||
BufferReader buffer = new BufferReader(binaryData);
|
||||
@@ -185,7 +185,7 @@ namespace YooAsset
|
||||
if (fileVersion != CatalogDefine.FileVersion)
|
||||
throw new Exception($"The catalog file version are not compatible : {fileVersion} != {CatalogDefine.FileVersion}");
|
||||
|
||||
DefaultBuildinFileCatalog catalog = new DefaultBuildinFileCatalog();
|
||||
DefaultBuiltinFileCatalog catalog = new DefaultBuiltinFileCatalog();
|
||||
{
|
||||
// 读取文件头信息
|
||||
catalog.FileVersion = fileVersion;
|
||||
@@ -194,10 +194,10 @@ namespace YooAsset
|
||||
|
||||
// 读取资源包列表
|
||||
int fileCount = buffer.ReadInt32();
|
||||
catalog.Wrappers = new List<DefaultBuildinFileCatalog.FileWrapper>(fileCount);
|
||||
catalog.Wrappers = new List<DefaultBuiltinFileCatalog.FileWrapper>(fileCount);
|
||||
for (int i = 0; i < fileCount; i++)
|
||||
{
|
||||
var fileWrapper = new DefaultBuildinFileCatalog.FileWrapper();
|
||||
var fileWrapper = new DefaultBuiltinFileCatalog.FileWrapper();
|
||||
fileWrapper.BundleGUID = buffer.ReadUTF8();
|
||||
fileWrapper.FileName = buffer.ReadUTF8();
|
||||
catalog.Wrappers.Add(fileWrapper);
|
||||
@@ -8,7 +8,7 @@ namespace YooAsset
|
||||
/// 内置资源清单目录
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
internal class DefaultBuildinFileCatalog
|
||||
internal class DefaultBuiltinFileCatalog
|
||||
{
|
||||
[Serializable]
|
||||
public class FileWrapper
|
||||
@@ -8,7 +8,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 内置文件系统
|
||||
/// </summary>
|
||||
internal class DefaultBuildinFileSystem : IFileSystem
|
||||
internal class DefaultBuiltinFileSystem : IFileSystem
|
||||
{
|
||||
public class FileWrapper
|
||||
{
|
||||
@@ -21,7 +21,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
protected readonly Dictionary<string, FileWrapper> _wrappers = new Dictionary<string, FileWrapper>(10000);
|
||||
protected readonly Dictionary<string, string> _buildinFilePathMapping = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _builtinFilePathMapping = new Dictionary<string, string>(10000);
|
||||
protected IFileSystem _unpackFileSystem;
|
||||
protected string _packageRoot;
|
||||
|
||||
@@ -81,16 +81,16 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 自定义参数:拷贝内置清单
|
||||
/// </summary>
|
||||
public bool CopyBuildinPackageManifest { private set; get; } = false;
|
||||
public bool CopyBuiltinPackageManifest { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:拷贝内置清单的目标目录
|
||||
/// 注意:该参数为空的时候,会获取默认的沙盒目录!
|
||||
/// </summary>
|
||||
public string CopyBuildinPackageManifestDestRoot { private set; get; }
|
||||
public string CopyBuiltinPackageManifestDestRoot { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:解密方法类
|
||||
/// 自定义参数:解密服务接口的实例类
|
||||
/// </summary>
|
||||
public IDecryptionServices DecryptionServices { private set; get; }
|
||||
|
||||
@@ -100,13 +100,13 @@ namespace YooAsset
|
||||
public IManifestRestoreServices ManifestServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:拷贝内置文件服务类
|
||||
/// 自定义参数:拷贝内置文件接口的实例类
|
||||
/// </summary>
|
||||
public ICopyLocalFileServices CopyLocalFileServices { private set; get; }
|
||||
#endregion
|
||||
|
||||
|
||||
public DefaultBuildinFileSystem()
|
||||
public DefaultBuiltinFileSystem()
|
||||
{
|
||||
}
|
||||
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
||||
@@ -131,7 +131,7 @@ namespace YooAsset
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||
{
|
||||
// 注意:业务层的解压器会依赖该方法
|
||||
options.ImportFilePath = GetBuildinFileLoadPath(bundle);
|
||||
options.ImportFilePath = GetBuiltinFileLoadPath(bundle);
|
||||
return _unpackFileSystem.DownloadFileAsync(bundle, options);
|
||||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
@@ -153,7 +153,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
string error = $"{nameof(DefaultBuildinFileSystem)} not support load bundle type : {bundle.BundleType}";
|
||||
string error = $"{nameof(DefaultBuiltinFileSystem)} not support load bundle type : {bundle.BundleType}";
|
||||
var operation = new FSLoadBundleCompleteOperation(error);
|
||||
return operation;
|
||||
}
|
||||
@@ -184,11 +184,11 @@ namespace YooAsset
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST)
|
||||
{
|
||||
CopyBuildinPackageManifest = Convert.ToBoolean(value);
|
||||
CopyBuiltinPackageManifest = Convert.ToBoolean(value);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT)
|
||||
{
|
||||
CopyBuildinPackageManifestDestRoot = (string)value;
|
||||
CopyBuiltinPackageManifestDestRoot = (string)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||
{
|
||||
@@ -212,7 +212,7 @@ namespace YooAsset
|
||||
PackageName = packageName;
|
||||
|
||||
if (string.IsNullOrEmpty(packageRoot))
|
||||
_packageRoot = GetDefaultBuildinPackageRoot(packageName);
|
||||
_packageRoot = GetDefaultBuiltinPackageRoot(packageName);
|
||||
else
|
||||
_packageRoot = packageRoot;
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace YooAsset
|
||||
if (IsUnpackBundleFile(bundle))
|
||||
return _unpackFileSystem.GetBundleFilePath(bundle);
|
||||
|
||||
return GetBuildinFileLoadPath(bundle);
|
||||
return GetBuiltinFileLoadPath(bundle);
|
||||
}
|
||||
public virtual byte[] ReadBundleFileData(PackageBundle bundle)
|
||||
{
|
||||
@@ -281,7 +281,7 @@ namespace YooAsset
|
||||
|
||||
#if UNITY_ANDROID
|
||||
//TODO : 安卓平台内置文件属于APK压缩包内的文件。
|
||||
YooLogger.Error($"Android platform not support read buildin bundle file data !");
|
||||
YooLogger.Error($"Android platform not support read builtin bundle file data !");
|
||||
return null;
|
||||
#else
|
||||
if (bundle.Encrypted)
|
||||
@@ -292,7 +292,7 @@ namespace YooAsset
|
||||
return null;
|
||||
}
|
||||
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
@@ -303,7 +303,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
return FileUtility.ReadAllBytes(filePath);
|
||||
}
|
||||
#endif
|
||||
@@ -318,7 +318,7 @@ namespace YooAsset
|
||||
|
||||
#if UNITY_ANDROID
|
||||
//TODO : 安卓平台内置文件属于APK压缩包内的文件。
|
||||
YooLogger.Error($"Android platform not support read buildin bundle file text !");
|
||||
YooLogger.Error($"Android platform not support read builtin bundle file text !");
|
||||
return null;
|
||||
#else
|
||||
if (bundle.Encrypted)
|
||||
@@ -329,7 +329,7 @@ namespace YooAsset
|
||||
return null;
|
||||
}
|
||||
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
@@ -340,7 +340,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
return FileUtility.ReadAllText(filePath);
|
||||
}
|
||||
#endif
|
||||
@@ -368,38 +368,38 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
#region 内部方法
|
||||
protected string GetDefaultBuildinPackageRoot(string packageName)
|
||||
protected string GetDefaultBuiltinPackageRoot(string packageName)
|
||||
{
|
||||
string rootDirectory = YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||
string rootDirectory = YooAssetSettingsData.GetYooDefaultBuiltinRoot();
|
||||
return PathUtility.Combine(rootDirectory, packageName);
|
||||
}
|
||||
public string GetBuildinFileLoadPath(PackageBundle bundle)
|
||||
public string GetBuiltinFileLoadPath(PackageBundle bundle)
|
||||
{
|
||||
if (_buildinFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
if (_builtinFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
filePath = PathUtility.Combine(_packageRoot, bundle.FileName);
|
||||
_buildinFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
_builtinFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
public string GetBuildinPackageVersionFilePath()
|
||||
public string GetBuiltinPackageVersionFilePath()
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(PackageName);
|
||||
return PathUtility.Combine(_packageRoot, fileName);
|
||||
}
|
||||
public string GetBuildinPackageHashFilePath(string packageVersion)
|
||||
public string GetBuiltinPackageHashFilePath(string packageVersion)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(PackageName, packageVersion);
|
||||
return PathUtility.Combine(_packageRoot, fileName);
|
||||
}
|
||||
public string GetBuildinPackageManifestFilePath(string packageVersion)
|
||||
public string GetBuiltinPackageManifestFilePath(string packageVersion)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
||||
return PathUtility.Combine(_packageRoot, fileName);
|
||||
}
|
||||
public string GetCatalogBinaryFileLoadPath()
|
||||
{
|
||||
return PathUtility.Combine(_packageRoot, DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName);
|
||||
return PathUtility.Combine(_packageRoot, DefaultBuiltinFileSystemDefine.BuiltinCatalogBinaryFileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -409,7 +409,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_wrappers.ContainsKey(bundleGUID))
|
||||
{
|
||||
YooLogger.Error($"{nameof(DefaultBuildinFileSystem)} has element : {bundleGUID}");
|
||||
YooLogger.Error($"{nameof(DefaultBuiltinFileSystem)} has element : {bundleGUID}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundle(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
@@ -445,7 +445,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundleAsync(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
@@ -1,16 +1,16 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DefaultBuildinFileSystemDefine
|
||||
internal class DefaultBuiltinFileSystemDefine
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置清单JSON文件名称
|
||||
/// </summary>
|
||||
public const string BuildinCatalogJsonFileName = "BuildinCatalog.json";
|
||||
public const string BuiltinCatalogJsonFileName = "BuiltinCatalog.json";
|
||||
|
||||
/// <summary>
|
||||
/// 内置清单二进制文件名称
|
||||
/// </summary>
|
||||
public const string BuildinCatalogBinaryFileName = "BuildinCatalog.bytes";
|
||||
public const string BuiltinCatalogBinaryFileName = "BuiltinCatalog.bytes";
|
||||
}
|
||||
}
|
||||
@@ -8,23 +8,23 @@ namespace YooAsset
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadBuildinPackageVersion,
|
||||
CopyBuildinPackageHash,
|
||||
CopyBuildinPackageManifest,
|
||||
LoadBuiltinPackageVersion,
|
||||
CopyBuiltinPackageHash,
|
||||
CopyBuiltinPackageManifest,
|
||||
InitUnpackFileSystem,
|
||||
LoadCatalogFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
|
||||
private CopyBuildinFileOperation _copyBuildinHashFileOp;
|
||||
private CopyBuildinFileOperation _copyBuildinManifestFileOp;
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private RequestBuiltinPackageVersionOperation _requestBuiltinPackageVersionOp;
|
||||
private CopyBuiltinFileOperation _copyBuiltinHashFileOp;
|
||||
private CopyBuiltinFileOperation _copyBuiltinManifestFileOp;
|
||||
private FSInitializeFileSystemOperation _initUnpackFIleSystemOp;
|
||||
private LoadBuildinCatalogFileOperation _loadBuildinCatalogFileOp;
|
||||
private LoadBuiltinCatalogFileOperation _loadBuiltinCatalogFileOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal DBFSInitializeOperation(DefaultBuildinFileSystem fileSystem)
|
||||
internal DBFSInitializeOperation(DefaultBuiltinFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
@@ -33,10 +33,10 @@ namespace YooAsset
|
||||
#if UNITY_WEBGL
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"{nameof(DefaultBuildinFileSystem)} is not support WEBGL platform !";
|
||||
Error = $"{nameof(DefaultBuiltinFileSystem)} is not support WEBGL platform !";
|
||||
#else
|
||||
if (_fileSystem.CopyBuildinPackageManifest)
|
||||
_steps = ESteps.LoadBuildinPackageVersion;
|
||||
if (_fileSystem.CopyBuiltinPackageManifest)
|
||||
_steps = ESteps.LoadBuiltinPackageVersion;
|
||||
else
|
||||
_steps = ESteps.InitUnpackFileSystem;
|
||||
#endif
|
||||
@@ -46,76 +46,76 @@ namespace YooAsset
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadBuildinPackageVersion)
|
||||
if (_steps == ESteps.LoadBuiltinPackageVersion)
|
||||
{
|
||||
if (_requestBuildinPackageVersionOp == null)
|
||||
if (_requestBuiltinPackageVersionOp == null)
|
||||
{
|
||||
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
|
||||
_requestBuildinPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestBuildinPackageVersionOp);
|
||||
_requestBuiltinPackageVersionOp = new RequestBuiltinPackageVersionOperation(_fileSystem);
|
||||
_requestBuiltinPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestBuiltinPackageVersionOp);
|
||||
}
|
||||
|
||||
_requestBuildinPackageVersionOp.UpdateOperation();
|
||||
if (_requestBuildinPackageVersionOp.IsDone == false)
|
||||
_requestBuiltinPackageVersionOp.UpdateOperation();
|
||||
if (_requestBuiltinPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_requestBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
if (_requestBuiltinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CopyBuildinPackageHash;
|
||||
_steps = ESteps.CopyBuiltinPackageHash;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _requestBuildinPackageVersionOp.Error;
|
||||
Error = _requestBuiltinPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CopyBuildinPackageHash)
|
||||
if (_steps == ESteps.CopyBuiltinPackageHash)
|
||||
{
|
||||
if (_copyBuildinHashFileOp == null)
|
||||
if (_copyBuiltinHashFileOp == null)
|
||||
{
|
||||
string packageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||
string packageVersion = _requestBuiltinPackageVersionOp.PackageVersion;
|
||||
string destFilePath = GetCopyPackageHashDestPath(packageVersion);
|
||||
string sourceFilePath = _fileSystem.GetBuildinPackageHashFilePath(packageVersion);
|
||||
_copyBuildinHashFileOp = new CopyBuildinFileOperation(sourceFilePath, destFilePath);
|
||||
_copyBuildinHashFileOp.StartOperation();
|
||||
AddChildOperation(_copyBuildinHashFileOp);
|
||||
string sourceFilePath = _fileSystem.GetBuiltinPackageHashFilePath(packageVersion);
|
||||
_copyBuiltinHashFileOp = new CopyBuiltinFileOperation(sourceFilePath, destFilePath);
|
||||
_copyBuiltinHashFileOp.StartOperation();
|
||||
AddChildOperation(_copyBuiltinHashFileOp);
|
||||
}
|
||||
|
||||
_copyBuildinHashFileOp.UpdateOperation();
|
||||
if (_copyBuildinHashFileOp.IsDone == false)
|
||||
_copyBuiltinHashFileOp.UpdateOperation();
|
||||
if (_copyBuiltinHashFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_copyBuildinHashFileOp.Status == EOperationStatus.Succeed)
|
||||
if (_copyBuiltinHashFileOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CopyBuildinPackageManifest;
|
||||
_steps = ESteps.CopyBuiltinPackageManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _copyBuildinHashFileOp.Error;
|
||||
Error = _copyBuiltinHashFileOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CopyBuildinPackageManifest)
|
||||
if (_steps == ESteps.CopyBuiltinPackageManifest)
|
||||
{
|
||||
if (_copyBuildinManifestFileOp == null)
|
||||
if (_copyBuiltinManifestFileOp == null)
|
||||
{
|
||||
string packageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||
string packageVersion = _requestBuiltinPackageVersionOp.PackageVersion;
|
||||
string destFilePath = GetCopyPackageManifestDestPath(packageVersion);
|
||||
string sourceFilePath = _fileSystem.GetBuildinPackageManifestFilePath(packageVersion);
|
||||
_copyBuildinManifestFileOp = new CopyBuildinFileOperation(sourceFilePath, destFilePath);
|
||||
_copyBuildinManifestFileOp.StartOperation();
|
||||
AddChildOperation(_copyBuildinManifestFileOp);
|
||||
string sourceFilePath = _fileSystem.GetBuiltinPackageManifestFilePath(packageVersion);
|
||||
_copyBuiltinManifestFileOp = new CopyBuiltinFileOperation(sourceFilePath, destFilePath);
|
||||
_copyBuiltinManifestFileOp.StartOperation();
|
||||
AddChildOperation(_copyBuiltinManifestFileOp);
|
||||
}
|
||||
|
||||
_copyBuildinManifestFileOp.UpdateOperation();
|
||||
if (_copyBuildinManifestFileOp.IsDone == false)
|
||||
_copyBuiltinManifestFileOp.UpdateOperation();
|
||||
if (_copyBuiltinManifestFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_copyBuildinManifestFileOp.Status == EOperationStatus.Succeed)
|
||||
if (_copyBuiltinManifestFileOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.InitUnpackFileSystem;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _copyBuildinManifestFileOp.Error;
|
||||
Error = _copyBuiltinManifestFileOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,20 +163,20 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.LoadCatalogFile)
|
||||
{
|
||||
if (_loadBuildinCatalogFileOp == null)
|
||||
if (_loadBuiltinCatalogFileOp == null)
|
||||
{
|
||||
_loadBuildinCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
|
||||
_loadBuildinCatalogFileOp.StartOperation();
|
||||
AddChildOperation(_loadBuildinCatalogFileOp);
|
||||
_loadBuiltinCatalogFileOp = new LoadBuiltinCatalogFileOperation(_fileSystem);
|
||||
_loadBuiltinCatalogFileOp.StartOperation();
|
||||
AddChildOperation(_loadBuiltinCatalogFileOp);
|
||||
}
|
||||
|
||||
_loadBuildinCatalogFileOp.UpdateOperation();
|
||||
if (_loadBuildinCatalogFileOp.IsDone == false)
|
||||
_loadBuiltinCatalogFileOp.UpdateOperation();
|
||||
if (_loadBuiltinCatalogFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadBuildinCatalogFileOp.Status == EOperationStatus.Succeed)
|
||||
if (_loadBuiltinCatalogFileOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
var catalog = _loadBuildinCatalogFileOp.Catalog;
|
||||
var catalog = _loadBuiltinCatalogFileOp.Catalog;
|
||||
if (catalog == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
@@ -195,11 +195,11 @@ namespace YooAsset
|
||||
|
||||
foreach (var wrapper in catalog.Wrappers)
|
||||
{
|
||||
var fileWrapper = new DefaultBuildinFileSystem.FileWrapper(wrapper.FileName);
|
||||
var fileWrapper = new DefaultBuiltinFileSystem.FileWrapper(wrapper.FileName);
|
||||
_fileSystem.RecordCatalogFile(wrapper.BundleGUID, fileWrapper);
|
||||
}
|
||||
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' buildin catalog files count : {catalog.Wrappers.Count}");
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' builtin catalog files count : {catalog.Wrappers.Count}");
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
@@ -207,14 +207,14 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadBuildinCatalogFileOp.Error;
|
||||
Error = _loadBuiltinCatalogFileOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetCopyManifestFileRoot()
|
||||
{
|
||||
string destRoot = _fileSystem.CopyBuildinPackageManifestDestRoot;
|
||||
string destRoot = _fileSystem.CopyBuiltinPackageManifestDestRoot;
|
||||
if (string.IsNullOrEmpty(destRoot))
|
||||
{
|
||||
string defaultCacheRoot = YooAssetSettingsData.GetYooDefaultCacheRoot();
|
||||
@@ -16,7 +16,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private readonly PackageBundle _bundle;
|
||||
private AssetBundleCreateRequest _createRequest;
|
||||
private AssetBundle _assetBundle;
|
||||
@@ -24,7 +24,7 @@ namespace YooAsset
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DBFSLoadAssetBundleOperation(DefaultBuildinFileSystem fileSystem, PackageBundle bundle)
|
||||
internal DBFSLoadAssetBundleOperation(DefaultBuiltinFileSystem fileSystem, PackageBundle bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
@@ -64,7 +64,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||
string filePath = _fileSystem.GetBuiltinFileLoadPath(_bundle);
|
||||
_assetBundle = AssetBundle.LoadFromFile(filePath);
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||
string filePath = _fileSystem.GetBuiltinFileLoadPath(_bundle);
|
||||
_createRequest = AssetBundle.LoadFromFileAsync(filePath);
|
||||
}
|
||||
}
|
||||
@@ -110,14 +110,14 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Failed to load encrypted buildin asset bundle file : {_bundle.BundleName}";
|
||||
Error = $"Failed to load encrypted builtin asset bundle file : {_bundle.BundleName}";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Failed to load buildin asset bundle file : {_bundle.BundleName}";
|
||||
Error = $"Failed to load builtin asset bundle file : {_bundle.BundleName}";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
}
|
||||
@@ -150,16 +150,16 @@ namespace YooAsset
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadBuildinRawBundle,
|
||||
LoadBuiltinRawBundle,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private readonly PackageBundle _bundle;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DBFSLoadRawBundleOperation(DefaultBuildinFileSystem fileSystem, PackageBundle bundle)
|
||||
internal DBFSLoadRawBundleOperation(DefaultBuiltinFileSystem fileSystem, PackageBundle bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
@@ -168,22 +168,22 @@ namespace YooAsset
|
||||
{
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
_steps = ESteps.LoadBuildinRawBundle;
|
||||
_steps = ESteps.LoadBuiltinRawBundle;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadBuildinRawBundle)
|
||||
if (_steps == ESteps.LoadBuiltinRawBundle)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||
string filePath = _fileSystem.GetBuiltinFileLoadPath(_bundle);
|
||||
|
||||
#if UNITY_ANDROID
|
||||
//TODO : 安卓平台内置文件属于APK压缩包内的文件。
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Can not load android buildin raw bundle file : {filePath}";
|
||||
Error = $"Can not load android builtin raw bundle file : {filePath}";
|
||||
YooLogger.Error(Error);
|
||||
#else
|
||||
if (File.Exists(filePath))
|
||||
@@ -196,7 +196,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Can not found buildin raw bundle file : {filePath}";
|
||||
Error = $"Can not found builtin raw bundle file : {filePath}";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DBFSLoadPackageManifestOperation : FSLoadPackageManifestOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestBuiltinPackageHash,
|
||||
LoadBuiltinPackageManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private RequestBuiltinPackageHashOperation _requestBuiltinPackageHashOp;
|
||||
private LoadBuiltinPackageManifestOperation _loadBuiltinPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
public DBFSLoadPackageManifestOperation(DefaultBuiltinFileSystem fileSystem, string packageVersion)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestBuiltinPackageHash;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestBuiltinPackageHash)
|
||||
{
|
||||
if (_requestBuiltinPackageHashOp == null)
|
||||
{
|
||||
_requestBuiltinPackageHashOp = new RequestBuiltinPackageHashOperation(_fileSystem, _packageVersion);
|
||||
_requestBuiltinPackageHashOp.StartOperation();
|
||||
AddChildOperation(_requestBuiltinPackageHashOp);
|
||||
}
|
||||
|
||||
_requestBuiltinPackageHashOp.UpdateOperation();
|
||||
if (_requestBuiltinPackageHashOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_requestBuiltinPackageHashOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadBuiltinPackageManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _requestBuiltinPackageHashOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadBuiltinPackageManifest)
|
||||
{
|
||||
if (_loadBuiltinPackageManifestOp == null)
|
||||
{
|
||||
string packageHash = _requestBuiltinPackageHashOp.PackageHash;
|
||||
_loadBuiltinPackageManifestOp = new LoadBuiltinPackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||
_loadBuiltinPackageManifestOp.StartOperation();
|
||||
AddChildOperation(_loadBuiltinPackageManifestOp);
|
||||
}
|
||||
|
||||
_loadBuiltinPackageManifestOp.UpdateOperation();
|
||||
if (_loadBuiltinPackageManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadBuiltinPackageManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Manifest = _loadBuiltinPackageManifestOp.Manifest;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadBuiltinPackageManifestOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,12 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private RequestBuiltinPackageVersionOperation _requestBuiltinPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DBFSRequestPackageVersionOperation(DefaultBuildinFileSystem fileSystem)
|
||||
internal DBFSRequestPackageVersionOperation(DefaultBuiltinFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
@@ -30,28 +30,28 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.RequestPackageVersion)
|
||||
{
|
||||
if (_requestBuildinPackageVersionOp == null)
|
||||
if (_requestBuiltinPackageVersionOp == null)
|
||||
{
|
||||
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
|
||||
_requestBuildinPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestBuildinPackageVersionOp);
|
||||
_requestBuiltinPackageVersionOp = new RequestBuiltinPackageVersionOperation(_fileSystem);
|
||||
_requestBuiltinPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestBuiltinPackageVersionOp);
|
||||
}
|
||||
|
||||
_requestBuildinPackageVersionOp.UpdateOperation();
|
||||
if (_requestBuildinPackageVersionOp.IsDone == false)
|
||||
_requestBuiltinPackageVersionOp.UpdateOperation();
|
||||
if (_requestBuiltinPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_requestBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
if (_requestBuiltinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
PackageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||
PackageVersion = _requestBuiltinPackageVersionOp.PackageVersion;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _requestBuildinPackageVersionOp.Error;
|
||||
Error = _requestBuiltinPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class CopyBuildinFileOperation : AsyncOperationBase
|
||||
internal class CopyBuiltinFileOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace YooAsset
|
||||
private readonly string _destFilePath;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public CopyBuildinFileOperation(string sourceFilePath, string destFilePath)
|
||||
public CopyBuiltinFileOperation(string sourceFilePath, string destFilePath)
|
||||
{
|
||||
_sourceFilePath = sourceFilePath;
|
||||
_destFilePath = destFilePath;
|
||||
@@ -61,7 +61,7 @@ namespace YooAsset
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
YooLogger.Warning($"Failed copy buildin file : {ex.Message}");
|
||||
YooLogger.Warning($"Failed copy builtin file : {ex.Message}");
|
||||
_steps = ESteps.UnpackFile;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class LoadBuildinCatalogFileOperation : AsyncOperationBase
|
||||
internal sealed class LoadBuiltinCatalogFileOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -14,7 +14,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||
private byte[] _fileData;
|
||||
private ESteps _steps = ESteps.None;
|
||||
@@ -22,9 +22,9 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 内置资源目录
|
||||
/// </summary>
|
||||
public DefaultBuildinFileCatalog Catalog;
|
||||
public DefaultBuiltinFileCatalog Catalog;
|
||||
|
||||
internal LoadBuildinCatalogFileOperation(DefaultBuildinFileSystem fileSystem)
|
||||
internal LoadBuiltinCatalogFileOperation(DefaultBuiltinFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class LoadBuildinPackageManifestOperation : AsyncOperationBase
|
||||
internal class LoadBuiltinPackageManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -14,7 +14,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private readonly string _packageHash;
|
||||
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||
@@ -28,7 +28,7 @@ namespace YooAsset
|
||||
public PackageManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
internal LoadBuildinPackageManifestOperation(DefaultBuildinFileSystem fileSystem, string packageVersion, string packageHash)
|
||||
internal LoadBuiltinPackageManifestOperation(DefaultBuiltinFileSystem fileSystem, string packageVersion, string packageHash)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
@@ -45,7 +45,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.TryLoadFileData)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinPackageManifestFilePath(_packageVersion);
|
||||
string filePath = _fileSystem.GetBuiltinPackageManifestFilePath(_packageVersion);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
_fileData = File.ReadAllBytes(filePath);
|
||||
@@ -61,7 +61,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_webDataRequestOp == null)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinPackageManifestFilePath(_packageVersion);
|
||||
string filePath = _fileSystem.GetBuiltinPackageManifestFilePath(_packageVersion);
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_webDataRequestOp = new UnityWebDataRequestOperation(url, 60);
|
||||
_webDataRequestOp.StartOperation();
|
||||
@@ -95,7 +95,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to verify buildin package manifest file !";
|
||||
Error = "Failed to verify builtin package manifest file !";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class RequestBuildinPackageHashOperation : AsyncOperationBase
|
||||
internal class RequestBuiltinPackageHashOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
@@ -24,7 +24,7 @@ namespace YooAsset
|
||||
public string PackageHash { private set; get; }
|
||||
|
||||
|
||||
internal RequestBuildinPackageHashOperation(DefaultBuildinFileSystem fileSystem, string packageVersion)
|
||||
internal RequestBuiltinPackageHashOperation(DefaultBuiltinFileSystem fileSystem, string packageVersion)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
@@ -40,7 +40,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.TryLoadPackageHash)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinPackageHashFilePath(_packageVersion);
|
||||
string filePath = _fileSystem.GetBuiltinPackageHashFilePath(_packageVersion);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
PackageHash = File.ReadAllText(filePath);
|
||||
@@ -56,7 +56,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_webTextRequestOp == null)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinPackageHashFilePath(_packageVersion);
|
||||
string filePath = _fileSystem.GetBuiltinPackageHashFilePath(_packageVersion);
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_webTextRequestOp = new UnityWebTextRequestOperation(url, 60);
|
||||
_webTextRequestOp.StartOperation();
|
||||
@@ -86,7 +86,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Buildin package hash file content is empty !";
|
||||
Error = $"Builtin package hash file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class RequestBuildinPackageVersionOperation : AsyncOperationBase
|
||||
internal class RequestBuiltinPackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace YooAsset
|
||||
public string PackageVersion { private set; get; }
|
||||
|
||||
|
||||
internal RequestBuildinPackageVersionOperation(DefaultBuildinFileSystem fileSystem)
|
||||
internal RequestBuiltinPackageVersionOperation(DefaultBuiltinFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.TryLoadPackageVersion)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinPackageVersionFilePath();
|
||||
string filePath = _fileSystem.GetBuiltinPackageVersionFilePath();
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
PackageVersion = File.ReadAllText(filePath);
|
||||
@@ -54,7 +54,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_webTextRequestOp == null)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinPackageVersionFilePath();
|
||||
string filePath = _fileSystem.GetBuiltinPackageVersionFilePath();
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_webTextRequestOp = new UnityWebTextRequestOperation(url, 60);
|
||||
_webTextRequestOp.StartOperation();
|
||||
@@ -84,7 +84,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Buildin package version file content is empty !";
|
||||
Error = $"Builtin package version file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace YooAsset
|
||||
|
||||
#region 自定义参数
|
||||
/// <summary>
|
||||
/// 自定义参数:远程服务接口
|
||||
/// 自定义参数:远程服务接口的实例类
|
||||
/// </summary>
|
||||
public IRemoteServices RemoteServices { private set; get; }
|
||||
|
||||
@@ -96,6 +96,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public int DownloadMaxRequestPerFrame { private set; get; } = int.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:下载任务的看门狗机制监控时间
|
||||
/// </summary>
|
||||
public int DownloadWatchDogTime { private set; get; } = int.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:启用断点续传的最小尺寸
|
||||
/// </summary>
|
||||
@@ -107,7 +112,7 @@ namespace YooAsset
|
||||
public List<long> ResumeDownloadResponseCodes { private set; get; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:解密方法类
|
||||
/// 自定义参数:解密服务接口的实例类
|
||||
/// </summary>
|
||||
public IDecryptionServices DecryptionServices { private set; get; }
|
||||
|
||||
@@ -117,7 +122,7 @@ namespace YooAsset
|
||||
public IManifestRestoreServices ManifestServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:拷贝内置文件服务类
|
||||
/// 自定义参数:拷贝内置文件接口的实例类
|
||||
/// </summary>
|
||||
public ICopyLocalFileServices CopyLocalFileServices { private set; get; }
|
||||
#endregion
|
||||
@@ -252,6 +257,11 @@ namespace YooAsset
|
||||
int convertValue = Convert.ToInt32(value);
|
||||
DownloadMaxRequestPerFrame = Mathf.Clamp(convertValue, 1, int.MaxValue);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DOWNLOAD_WATCH_DOG_TIME)
|
||||
{
|
||||
int convertValue = Convert.ToInt32(value);
|
||||
DownloadWatchDogTime = Mathf.Clamp(convertValue, 1, int.MaxValue);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.RESUME_DOWNLOAD_MINMUM_SIZE)
|
||||
{
|
||||
ResumeDownloadMinimumSize = Convert.ToInt64(value);
|
||||
|
||||
@@ -17,6 +17,11 @@ namespace YooAsset
|
||||
protected readonly PackageBundle _bundle;
|
||||
protected readonly string _tempFilePath;
|
||||
|
||||
private bool _watchDogInit = false;
|
||||
private bool _watchDogAborted = false;
|
||||
private ulong _lastDownloadBytes;
|
||||
private double _lastGetDataTime;
|
||||
|
||||
/// <summary>
|
||||
/// 引用计数
|
||||
/// </summary>
|
||||
@@ -33,6 +38,47 @@ namespace YooAsset
|
||||
return $"RefCount : {RefCount}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新看门狗监测
|
||||
/// 说明:监控时间范围内,如果没有接收到任何下载数据,那么直接终止任务!
|
||||
/// </summary>
|
||||
protected void UpdateWatchDog()
|
||||
{
|
||||
if (_fileSystem.DownloadWatchDogTime == int.MaxValue)
|
||||
return;
|
||||
|
||||
if (_watchDogAborted)
|
||||
return;
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
double realtimeSinceStartup = UnityEngine.Time.realtimeSinceStartupAsDouble;
|
||||
#else
|
||||
double realtimeSinceStartup = UnityEngine.Time.realtimeSinceStartup;
|
||||
#endif
|
||||
|
||||
if (_watchDogInit == false)
|
||||
{
|
||||
_watchDogInit = true;
|
||||
_lastDownloadBytes = 0;
|
||||
_lastGetDataTime = realtimeSinceStartup;
|
||||
}
|
||||
|
||||
if (_webRequest.downloadedBytes != _lastDownloadBytes)
|
||||
{
|
||||
_lastDownloadBytes = _webRequest.downloadedBytes;
|
||||
_lastGetDataTime = realtimeSinceStartup;
|
||||
}
|
||||
else
|
||||
{
|
||||
double deltaTime = realtimeSinceStartup - _lastGetDataTime;
|
||||
if (deltaTime > _fileSystem.DownloadWatchDogTime)
|
||||
{
|
||||
_watchDogAborted = true;
|
||||
InternalAbort(); //终止网络请求
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 减少引用计数
|
||||
/// </summary>
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine.Networking;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class UnityDownloadLocalFileOperation : UnityDownloadFileOperation
|
||||
internal sealed class UnityDownloadLocalFileOperation : UnityDownloadFileOperation
|
||||
{
|
||||
private VerifyTempFileOperation _verifyOperation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
@@ -42,6 +42,8 @@ namespace YooAsset
|
||||
DownloadProgress = _webRequest.downloadProgress;
|
||||
DownloadedBytes = (long)_webRequest.downloadedBytes;
|
||||
Progress = DownloadProgress;
|
||||
|
||||
UpdateWatchDog();
|
||||
if (_webRequest.isDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ namespace YooAsset
|
||||
DownloadProgress = _webRequest.downloadProgress;
|
||||
DownloadedBytes = (long)_webRequest.downloadedBytes;
|
||||
Progress = DownloadProgress;
|
||||
|
||||
UpdateWatchDog();
|
||||
if (_webRequest.isDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ namespace YooAsset
|
||||
DownloadProgress = _webRequest.downloadProgress;
|
||||
DownloadedBytes = _fileOriginLength + (long)_webRequest.downloadedBytes;
|
||||
Progress = DownloadProgress;
|
||||
|
||||
UpdateWatchDog();
|
||||
if (_webRequest.isDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
@@ -7,6 +8,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
internal class DefaultEditorFileSystem : IFileSystem
|
||||
{
|
||||
protected readonly Dictionary<string, string> _records = new Dictionary<string, string>(10000);
|
||||
protected string _packageRoot;
|
||||
|
||||
/// <summary>
|
||||
@@ -37,15 +39,30 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
#region 自定义参数
|
||||
/// <summary>
|
||||
/// 模拟WebGL平台模式
|
||||
/// </summary>
|
||||
public bool VirtualWebGLMode { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 模拟虚拟下载模式
|
||||
/// </summary>
|
||||
public bool VirtualDownloadMode { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 模拟虚拟下载的网速(单位:字节)
|
||||
/// </summary>
|
||||
public int VirtualDownloadSpeed { private set; get; } = 1024;
|
||||
|
||||
/// <summary>
|
||||
/// 异步模拟加载最小帧数
|
||||
/// </summary>
|
||||
public int _asyncSimulateMinFrame = 1;
|
||||
public int AsyncSimulateMinFrame { private set; get; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 异步模拟加载最大帧数
|
||||
/// </summary>
|
||||
public int _asyncSimulateMaxFrame = 1;
|
||||
public int AsyncSimulateMaxFrame { private set; get; } = 1;
|
||||
#endregion
|
||||
|
||||
public DefaultEditorFileSystem()
|
||||
@@ -73,7 +90,10 @@ namespace YooAsset
|
||||
}
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
string mainURL = bundle.BundleName;
|
||||
options.SetURL(mainURL, mainURL);
|
||||
var downloader = new DownloadVirtualBundleOperation(this, bundle, options);
|
||||
return downloader;
|
||||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
{
|
||||
@@ -92,13 +112,25 @@ namespace YooAsset
|
||||
|
||||
public virtual void SetParameter(string name, object value)
|
||||
{
|
||||
if (name == FileSystemParametersDefine.ASYNC_SIMULATE_MIN_FRAME)
|
||||
if (name == FileSystemParametersDefine.VIRTUAL_WEBGL_MODE)
|
||||
{
|
||||
_asyncSimulateMinFrame = Convert.ToInt32(value);
|
||||
VirtualWebGLMode = Convert.ToBoolean(value);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.VIRTUAL_DOWNLOAD_MODE)
|
||||
{
|
||||
VirtualDownloadMode = Convert.ToBoolean(value);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.VIRTUAL_DOWNLOAD_SPEED)
|
||||
{
|
||||
VirtualDownloadSpeed = Convert.ToInt32(value);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.ASYNC_SIMULATE_MIN_FRAME)
|
||||
{
|
||||
AsyncSimulateMinFrame = Convert.ToInt32(value);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.ASYNC_SIMULATE_MAX_FRAME)
|
||||
{
|
||||
_asyncSimulateMaxFrame = Convert.ToInt32(value);
|
||||
AsyncSimulateMaxFrame = Convert.ToInt32(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -124,11 +156,21 @@ namespace YooAsset
|
||||
}
|
||||
public virtual bool Exists(PackageBundle bundle)
|
||||
{
|
||||
return true;
|
||||
if (VirtualDownloadMode)
|
||||
{
|
||||
return _records.ContainsKey(bundle.BundleGUID);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public virtual bool NeedDownload(PackageBundle bundle)
|
||||
{
|
||||
return false;
|
||||
if (Belong(bundle) == false)
|
||||
return false;
|
||||
|
||||
return Exists(bundle) == false;
|
||||
}
|
||||
public virtual bool NeedUnpack(PackageBundle bundle)
|
||||
{
|
||||
@@ -165,6 +207,11 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
#region 内部方法
|
||||
public void RecordDownloadFile(PackageBundle bundle)
|
||||
{
|
||||
if (_records.ContainsKey(bundle.BundleGUID) == false)
|
||||
_records.Add(bundle.BundleGUID, bundle.BundleName);
|
||||
}
|
||||
public string GetEditorPackageVersionFilePath()
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(PackageName);
|
||||
@@ -182,12 +229,12 @@ namespace YooAsset
|
||||
}
|
||||
public int GetAsyncSimulateFrame()
|
||||
{
|
||||
if (_asyncSimulateMinFrame > _asyncSimulateMaxFrame)
|
||||
if (AsyncSimulateMinFrame > AsyncSimulateMaxFrame)
|
||||
{
|
||||
_asyncSimulateMinFrame = _asyncSimulateMaxFrame;
|
||||
AsyncSimulateMinFrame = AsyncSimulateMaxFrame;
|
||||
}
|
||||
|
||||
return UnityEngine.Random.Range(_asyncSimulateMinFrame, _asyncSimulateMaxFrame + 1);
|
||||
return UnityEngine.Random.Range(AsyncSimulateMinFrame, AsyncSimulateMaxFrame + 1);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace YooAsset
|
||||
protected enum ESteps
|
||||
{
|
||||
None,
|
||||
CheckExist,
|
||||
DownloadFile,
|
||||
LoadAssetBundle,
|
||||
CheckResult,
|
||||
@@ -14,6 +15,7 @@ namespace YooAsset
|
||||
|
||||
private readonly DefaultEditorFileSystem _fileSystem;
|
||||
private readonly PackageBundle _bundle;
|
||||
protected FSDownloadFileOperation _downloadFileOp;
|
||||
private int _asyncSimulateFrame;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
@@ -24,26 +26,74 @@ namespace YooAsset
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.DownloadFile;
|
||||
_steps = ESteps.CheckExist;
|
||||
_asyncSimulateFrame = _fileSystem.GetAsyncSimulateFrame();
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CheckExist)
|
||||
{
|
||||
if (_fileSystem.Exists(_bundle))
|
||||
{
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
_steps = ESteps.LoadAssetBundle;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.DownloadFile;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
_asyncSimulateFrame = _fileSystem.GetAsyncSimulateFrame();
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
_steps = ESteps.LoadAssetBundle;
|
||||
if (_downloadFileOp == null)
|
||||
{
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
|
||||
_downloadFileOp.StartOperation();
|
||||
AddChildOperation(_downloadFileOp);
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
_downloadFileOp.WaitForAsyncComplete();
|
||||
|
||||
_downloadFileOp.UpdateOperation();
|
||||
DownloadProgress = _downloadFileOp.DownloadProgress;
|
||||
DownloadedBytes = _downloadFileOp.DownloadedBytes;
|
||||
if (_downloadFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_downloadFileOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadAssetBundle;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _downloadFileOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadAssetBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
_steps = ESteps.CheckResult;
|
||||
if (_fileSystem.VirtualWebGLMode)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Virtual WebGL Mode only support asyn load method !";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.CheckResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DownloadVirtualBundleOperation : FSDownloadFileOperation
|
||||
{
|
||||
protected enum ESteps
|
||||
{
|
||||
None,
|
||||
CheckExists,
|
||||
CreateRequest,
|
||||
CheckRequest,
|
||||
TryAgain,
|
||||
Done,
|
||||
}
|
||||
|
||||
// 下载参数
|
||||
protected readonly DefaultEditorFileSystem _fileSystem;
|
||||
protected readonly DownloadFileOptions _options;
|
||||
protected UnityVirtualBundleRequestOperation _unityDownloadFileOp;
|
||||
|
||||
protected int _requestCount = 0;
|
||||
protected float _tryAgainTimer;
|
||||
protected int _failedTryAgain;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DownloadVirtualBundleOperation(DefaultEditorFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_options = options;
|
||||
_failedTryAgain = options.FailedTryAgain;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CheckExists;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
// 检测文件是否存在
|
||||
if (_steps == ESteps.CheckExists)
|
||||
{
|
||||
if (_fileSystem.Exists(Bundle))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
}
|
||||
|
||||
// 创建下载器
|
||||
if (_steps == ESteps.CreateRequest)
|
||||
{
|
||||
if (_options.IsValid() == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Download file options is invalid !";
|
||||
Debug.Log(Error);
|
||||
return;
|
||||
}
|
||||
|
||||
string url = GetRequestURL();
|
||||
int speed = _fileSystem.VirtualDownloadSpeed;
|
||||
_unityDownloadFileOp = new UnityVirtualBundleRequestOperation(Bundle, speed, url);
|
||||
_unityDownloadFileOp.StartOperation();
|
||||
_steps = ESteps.CheckRequest;
|
||||
}
|
||||
|
||||
// 检测下载结果
|
||||
if (_steps == ESteps.CheckRequest)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
_unityDownloadFileOp.WaitForAsyncComplete();
|
||||
|
||||
// 因为并发数量限制,下载器可能被挂起!
|
||||
if (_unityDownloadFileOp.Status == EOperationStatus.None)
|
||||
return;
|
||||
|
||||
_unityDownloadFileOp.UpdateOperation();
|
||||
Progress = _unityDownloadFileOp.Progress;
|
||||
DownloadedBytes = _unityDownloadFileOp.DownloadedBytes;
|
||||
DownloadProgress = _unityDownloadFileOp.DownloadProgress;
|
||||
if (_unityDownloadFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_unityDownloadFileOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_fileSystem.RecordDownloadFile(Bundle);
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsWaitForAsyncComplete == false && _failedTryAgain > 0)
|
||||
{
|
||||
_steps = ESteps.TryAgain;
|
||||
YooLogger.Warning($"Failed download : {_unityDownloadFileOp.URL} Try again !");
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _unityDownloadFileOp.Error;
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 重新尝试下载
|
||||
if (_steps == ESteps.TryAgain)
|
||||
{
|
||||
_tryAgainTimer += Time.unscaledDeltaTime;
|
||||
if (_tryAgainTimer > 1f)
|
||||
{
|
||||
_tryAgainTimer = 0f;
|
||||
_failedTryAgain--;
|
||||
Progress = 0f;
|
||||
DownloadProgress = 0f;
|
||||
DownloadedBytes = 0;
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取网络请求地址
|
||||
/// </summary>
|
||||
protected string GetRequestURL()
|
||||
{
|
||||
// 轮流返回请求地址
|
||||
_requestCount++;
|
||||
if (_requestCount % 2 == 0)
|
||||
return _options.FallbackURL;
|
||||
else
|
||||
return _options.MainURL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f043dc0e0f147334380cfd0720636544
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user