mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-30 05:28:46 +00:00
Compare commits
18 Commits
8329045a68
...
2.3.17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
101236db8a | ||
|
|
37de007b3f | ||
|
|
d570ba8d74 | ||
|
|
2a956099ae | ||
|
|
74037a5a29 | ||
|
|
861f850a32 | ||
|
|
8b1b5f988a | ||
|
|
efafd1173f | ||
|
|
03e49ff1fb | ||
|
|
ea34be1f00 | ||
|
|
831a9981e3 | ||
|
|
9de4aaa658 | ||
|
|
3579a23bd5 | ||
|
|
c865ddc7f2 | ||
|
|
0bde506aec | ||
|
|
15005b3d30 | ||
|
|
4caf733ac6 | ||
|
|
014b17f5cb |
@@ -2,6 +2,67 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [2.3.17] - 2025-10-30
|
||||
|
||||
**非常重要**:修复了#627优化导致的资源清单CRC值为空的问题。
|
||||
|
||||
该问题会导致下载的损坏文件验证通过。
|
||||
|
||||
影响范围:v2.3.15版本,v2.3.16版本。
|
||||
|
||||
**非常重要**:(#661) 修复了Package销毁过程中,遇到正在加载的AssetBundle会导致无法卸载的问题。
|
||||
|
||||
该问题是偶现,引擎会提示AssetBundle已经加载,无法加载新的文件,导致资源对象加载失败!
|
||||
|
||||
影响范围:所有版本!
|
||||
|
||||
### Improvements
|
||||
|
||||
- 重构并统一了资源清单的反序列化逻辑。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#645) 修复了着色器变种收集工具,在极端情况下变种收集不完整的问题。
|
||||
- (#646) 修复了EditorSimulateMode模式下开启模拟下载tag不生效的问题。
|
||||
- (#667) 修复了所有编辑器窗口针对中文IME的输入问题。
|
||||
- (#670) 修复了Catalog文件生成过程中白名单未考虑自定义清单前缀名。
|
||||
|
||||
### Improvements
|
||||
|
||||
- (#650) 解决互相依赖的资源包无法卸载的问题。需要开启宏定义:YOOASSET_EXPERIMENTAL
|
||||
- (#655) 优化了初始化的时候,缓存文件搜索效率。安卓平台性能提升1倍,IOS平台性能提升3倍。
|
||||
|
||||
### Added
|
||||
|
||||
- (#643) 新增构建参数,可以节省资源清单运行时内存
|
||||
|
||||
```csharp
|
||||
class ScriptableBuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用可寻址地址代替资源路径
|
||||
/// 说明:开启此项可以节省运行时清单占用的内存!
|
||||
/// </summary>
|
||||
public bool ReplaceAssetPathWithAddress = false;
|
||||
}
|
||||
```
|
||||
|
||||
- (#648) 新增初始化参数,可以自动释放引用计数为零的资源包
|
||||
|
||||
```csharp
|
||||
class InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 当资源引用计数为零的时候自动释放资源包
|
||||
/// </summary>
|
||||
public bool AutoUnloadBundleWhenUnused = false;
|
||||
}
|
||||
```
|
||||
|
||||
### Changed
|
||||
|
||||
- 程序集宏定义代码转移到扩展工程。参考MacroSupport文件夹。
|
||||
|
||||
## [2.3.16] - 2025-09-17
|
||||
|
||||
### Improvements
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public static string GetStreamingAssetsRoot()
|
||||
{
|
||||
return YooAssetSettingsData.GetYooDefaultBuiltinRoot();
|
||||
return YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,28 +43,28 @@ namespace YooAsset.Editor
|
||||
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
||||
}
|
||||
|
||||
// EBuiltinFileCopyOption
|
||||
public static EBuiltinFileCopyOption GetPackageBuiltinFileCopyOption(string packageName, string buildPipeline)
|
||||
// EBuildinFileCopyOption
|
||||
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuiltinFileCopyOption)}";
|
||||
return (EBuiltinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuiltinFileCopyOption.None);
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
||||
}
|
||||
public static void SetPackageBuiltinFileCopyOption(string packageName, string buildPipeline, EBuiltinFileCopyOption builtinFileCopyOption)
|
||||
public static void SetPackageBuildinFileCopyOption(string packageName, string buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuiltinFileCopyOption)}";
|
||||
EditorPrefs.SetInt(key, (int)builtinFileCopyOption);
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
||||
}
|
||||
|
||||
// BuildFileCopyParams
|
||||
public static string GetPackageBuiltinFileCopyParams(string packageName, string buildPipeline)
|
||||
public static string GetPackageBuildinFileCopyParams(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
}
|
||||
public static void SetPackageBuiltinFileCopyParams(string packageName, string buildPipeline, string builtinFileCopyParams)
|
||||
public static void SetPackageBuildinFileCopyParams(string packageName, string buildPipeline, string buildinFileCopyParams)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
EditorPrefs.SetString(key, builtinFileCopyParams);
|
||||
EditorPrefs.SetString(key, buildinFileCopyParams);
|
||||
}
|
||||
|
||||
// EncyptionServicesClassName
|
||||
|
||||
@@ -17,15 +17,15 @@ namespace YooAsset.Editor
|
||||
{
|
||||
var buildParameters = new EditorSimulateBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuiltinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildinFileRoot = 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.BuiltinFileCopyOption = EBuiltinFileCopyOption.None;
|
||||
buildParameters.BuiltinFileCopyParams = string.Empty;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = 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 BuiltinFileRoot;
|
||||
public string BuildinFileRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线名称
|
||||
@@ -86,12 +86,12 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝选项
|
||||
/// </summary>
|
||||
public EBuiltinFileCopyOption BuiltinFileCopyOption = EBuiltinFileCopyOption.None;
|
||||
public EBuildinFileCopyOption BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝参数
|
||||
/// </summary>
|
||||
public string BuiltinFileCopyParams;
|
||||
public string BuildinFileCopyParams;
|
||||
|
||||
/// <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 _builtinRootDirectory = string.Empty;
|
||||
private string _buildinRootDirectory = 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(BuiltinFileRoot))
|
||||
if (string.IsNullOrEmpty(BuildinFileRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuiltinFileRootIsNullOrEmpty, "Builtin file root is null or empty !");
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin 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 GetBuiltinRootDirectory()
|
||||
public virtual string GetBuildinRootDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_builtinRootDirectory))
|
||||
if (string.IsNullOrEmpty(_buildinRootDirectory))
|
||||
{
|
||||
_builtinRootDirectory = $"{BuiltinFileRoot}/{PackageName}";
|
||||
_buildinRootDirectory = $"{BuildinFileRoot}/{PackageName}";
|
||||
}
|
||||
return _builtinRootDirectory;
|
||||
return _buildinRootDirectory;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,9 +55,9 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 获取内置资源的根目录
|
||||
/// </summary>
|
||||
public string GetBuiltinRootDirectory()
|
||||
public string GetBuildinRootDirectory()
|
||||
{
|
||||
return Parameters.GetBuiltinRootDirectory();
|
||||
return Parameters.GetBuildinRootDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,30 +6,30 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuiltinFiles
|
||||
public class TaskCopyBuildinFiles
|
||||
{
|
||||
/// <summary>
|
||||
/// 拷贝首包资源文件
|
||||
/// </summary>
|
||||
internal void CopyBuiltinFilesToStreaming(BuildParametersContext buildParametersContext, PackageManifest manifest)
|
||||
internal void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, PackageManifest manifest)
|
||||
{
|
||||
EBuiltinFileCopyOption copyOption = buildParametersContext.Parameters.BuiltinFileCopyOption;
|
||||
EBuildinFileCopyOption copyOption = buildParametersContext.Parameters.BuildinFileCopyOption;
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
string builtinRootDirectory = buildParametersContext.GetBuiltinRootDirectory();
|
||||
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
||||
|
||||
// 清空内置文件的目录
|
||||
if (copyOption == EBuiltinFileCopyOption.ClearAndCopyAll || copyOption == EBuiltinFileCopyOption.ClearAndCopyByTags)
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.ClearAndCopyByTags)
|
||||
{
|
||||
EditorTools.ClearFolder(builtinRootDirectory);
|
||||
EditorTools.ClearFolder(buildinRootDirectory);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildPackageName, buildPackageVersion);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{builtinRootDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{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 = $"{builtinRootDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
@@ -45,38 +45,38 @@ namespace YooAsset.Editor
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildPackageName);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{builtinRootDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝文件列表(所有文件)
|
||||
if (copyOption == EBuiltinFileCopyOption.ClearAndCopyAll || copyOption == EBuiltinFileCopyOption.OnlyCopyAll)
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.OnlyCopyAll)
|
||||
{
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{builtinRootDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 拷贝文件列表(带标签的文件)
|
||||
if (copyOption == EBuiltinFileCopyOption.ClearAndCopyByTags || copyOption == EBuiltinFileCopyOption.OnlyCopyByTags)
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyByTags || copyOption == EBuildinFileCopyOption.OnlyCopyByTags)
|
||||
{
|
||||
string[] tags = buildParametersContext.Parameters.BuiltinFileCopyParams.Split(';');
|
||||
string[] tags = buildParametersContext.Parameters.BuildinFileCopyParams.Split(';');
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
if (packageBundle.HasTag(tags) == false)
|
||||
continue;
|
||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{builtinRootDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
BuildLogger.Log($"Builtin files copy complete: {builtinRootDirectory}");
|
||||
BuildLogger.Log($"Buildin files copy complete: {buildinRootDirectory}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,10 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
internal void CreateCatalogFile(BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string builtinRootDirectory = buildParametersContext.GetBuiltinRootDirectory();
|
||||
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||
var manifestServices = buildParametersContext.Parameters.ManifestRestoreServices;
|
||||
CatalogTools.CreateCatalogFile(manifestServices, buildPackageName, builtinRootDirectory);
|
||||
CatalogTools.CreateCatalogFile(manifestServices, buildPackageName, buildinRootDirectory);
|
||||
|
||||
// 刷新目录
|
||||
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 TaskCopyBuiltinFiles_BBP : TaskCopyBuiltinFiles, IBuildTask
|
||||
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
if (buildParametersContext.Parameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuiltinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParametersContext.Parameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.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 TaskCopyBuiltinFiles_BBP(),
|
||||
new TaskCopyBuildinFiles_BBP(),
|
||||
new TaskCreateCatalog_BBP()
|
||||
};
|
||||
return pipeline;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(false, false, context);
|
||||
CreateManifestFile(false, true, false, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
|
||||
@@ -6,16 +6,16 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuiltinFiles_RFBP : TaskCopyBuiltinFiles, IBuildTask
|
||||
public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
if (buildParameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuiltinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParametersContext.Parameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.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 TaskCopyBuiltinFiles_RFBP(),
|
||||
new TaskCopyBuildinFiles_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 TaskCopyBuiltinFiles_SBP : TaskCopyBuiltinFiles, IBuildTask
|
||||
public class TaskCopyBuildinFiles_SBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
if (buildParametersContext.Parameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuiltinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParametersContext.Parameters.BuiltinFileCopyOption != EBuiltinFileCopyOption.None)
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.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 TaskCopyBuiltinFiles_SBP(),
|
||||
new TaskCopyBuildinFiles_SBP(),
|
||||
new TaskCreateCatalog_SBP()
|
||||
};
|
||||
return pipeline;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
||||
PackageNameIsNullOrEmpty = 111,
|
||||
PackageVersionIsNullOrEmpty = 112,
|
||||
BuildOutputRootIsNullOrEmpty = 113,
|
||||
BuiltinFileRootIsNullOrEmpty = 114,
|
||||
BuildinFileRootIsNullOrEmpty = 114,
|
||||
PackageOutputDirectoryExists = 115,
|
||||
BuildPipelineIsNullOrEmpty = 116,
|
||||
BuildBundleTypeIsUnknown = 117,
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 首包资源文件的拷贝方式
|
||||
/// </summary>
|
||||
public enum EBuiltinFileCopyOption
|
||||
public enum EBuildinFileCopyOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 不拷贝任何文件
|
||||
@@ -127,35 +127,35 @@ namespace YooAsset.Editor
|
||||
});
|
||||
UIElementsTools.SetElementLabelMinWidth(enumField, LabelMinWidth);
|
||||
}
|
||||
protected void SetCopyBuiltinFileOptionField(EnumField enumField, TextField tagField)
|
||||
protected void SetCopyBuildinFileOptionField(EnumField enumField, TextField tagField)
|
||||
{
|
||||
// 首包文件拷贝选项
|
||||
var builtinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
enumField.Init(builtinFileCopyOption);
|
||||
enumField.SetValueWithoutNotify(builtinFileCopyOption);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
enumField.Init(buildinFileCopyOption);
|
||||
enumField.SetValueWithoutNotify(buildinFileCopyOption);
|
||||
enumField.style.width = StyleWidth;
|
||||
enumField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuiltinFileCopyOption(PackageName, PipelineName, (EBuiltinFileCopyOption)enumField.value);
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(PackageName, PipelineName, (EBuildinFileCopyOption)enumField.value);
|
||||
|
||||
// 设置内置资源标签显隐
|
||||
SetCopyBuiltinFileTagsVisible(tagField);
|
||||
SetCopyBuildinFileTagsVisible(tagField);
|
||||
});
|
||||
UIElementsTools.SetElementLabelMinWidth(enumField, LabelMinWidth);
|
||||
}
|
||||
protected void SetCopyBuiltinFileTagsVisible(TextField tagField)
|
||||
protected void SetCopyBuildinFileTagsVisible(TextField tagField)
|
||||
{
|
||||
var option = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
tagField.visible = option == EBuiltinFileCopyOption.ClearAndCopyByTags || option == EBuiltinFileCopyOption.OnlyCopyByTags;
|
||||
var option = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
tagField.visible = option == EBuildinFileCopyOption.ClearAndCopyByTags || option == EBuildinFileCopyOption.OnlyCopyByTags;
|
||||
}
|
||||
protected void SetCopyBuiltinFileTagsField(TextField textField)
|
||||
protected void SetCopyBuildinFileTagsField(TextField textField)
|
||||
{
|
||||
// 首包文件拷贝参数
|
||||
var builtinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyParams(PackageName, PipelineName);
|
||||
textField.SetValueWithoutNotify(builtinFileCopyParams);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
textField.SetValueWithoutNotify(buildinFileCopyParams);
|
||||
textField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuiltinFileCopyParams(PackageName, PipelineName, textField.value);
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(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 _copyBuiltinFileOptionField;
|
||||
protected TextField _copyBuiltinFileTagsField;
|
||||
protected EnumField _copyBuildinFileOptionField;
|
||||
protected TextField _copyBuildinFileTagsField;
|
||||
protected Toggle _clearBuildCacheToggle;
|
||||
protected Toggle _useAssetDependencyDBToggle;
|
||||
|
||||
@@ -60,13 +60,13 @@ namespace YooAsset.Editor
|
||||
SetOutputNameStyleField(_outputNameStyleField);
|
||||
|
||||
// 首包文件拷贝参数
|
||||
_copyBuiltinFileTagsField = Root.Q<TextField>("CopyBuiltinFileParam");
|
||||
SetCopyBuiltinFileTagsField(_copyBuiltinFileTagsField);
|
||||
SetCopyBuiltinFileTagsVisible(_copyBuiltinFileTagsField);
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
SetCopyBuildinFileTagsField(_copyBuildinFileTagsField);
|
||||
SetCopyBuildinFileTagsVisible(_copyBuildinFileTagsField);
|
||||
|
||||
// 首包文件拷贝选项
|
||||
_copyBuiltinFileOptionField = Root.Q<EnumField>("CopyBuiltinFileOption");
|
||||
SetCopyBuiltinFileOptionField(_copyBuiltinFileOptionField, _copyBuiltinFileTagsField);
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
SetCopyBuildinFileOptionField(_copyBuildinFileOptionField, _copyBuildinFileTagsField);
|
||||
|
||||
// 清理构建缓存
|
||||
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
@@ -99,15 +99,15 @@ namespace YooAsset.Editor
|
||||
protected virtual void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
var builtinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
var builtinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyParams(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(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.BuiltinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildinFileRoot = 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.BuiltinFileCopyOption = builtinFileCopyOption;
|
||||
buildParameters.BuiltinFileCopyParams = builtinFileCopyParams;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
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 Builtin File Option" value="Center" name="CopyBuiltinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Builtin File Param" name="CopyBuiltinFileParam" />
|
||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Param" name="CopyBuildinFileParam" />
|
||||
<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 builtinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
var builtinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyParams(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
|
||||
EditorSimulateBuildParameters buildParameters = new EditorSimulateBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuiltinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildinFileRoot = 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.BuiltinFileCopyOption = builtinFileCopyOption;
|
||||
buildParameters.BuiltinFileCopyParams = builtinFileCopyParams;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
|
||||
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 _copyBuiltinFileOptionField;
|
||||
protected TextField _copyBuiltinFileTagsField;
|
||||
protected EnumField _copyBuildinFileOptionField;
|
||||
protected TextField _copyBuildinFileTagsField;
|
||||
protected Toggle _clearBuildCacheToggle;
|
||||
protected Toggle _useAssetDependencyDBToggle;
|
||||
|
||||
@@ -55,13 +55,13 @@ namespace YooAsset.Editor
|
||||
SetOutputNameStyleField(_outputNameStyleField);
|
||||
|
||||
// 首包文件拷贝参数
|
||||
_copyBuiltinFileTagsField = Root.Q<TextField>("CopyBuiltinFileParam");
|
||||
SetCopyBuiltinFileTagsField(_copyBuiltinFileTagsField);
|
||||
SetCopyBuiltinFileTagsVisible(_copyBuiltinFileTagsField);
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
SetCopyBuildinFileTagsField(_copyBuildinFileTagsField);
|
||||
SetCopyBuildinFileTagsVisible(_copyBuildinFileTagsField);
|
||||
|
||||
// 首包文件拷贝选项
|
||||
_copyBuiltinFileOptionField = Root.Q<EnumField>("CopyBuiltinFileOption");
|
||||
SetCopyBuiltinFileOptionField(_copyBuiltinFileOptionField, _copyBuiltinFileTagsField);
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
SetCopyBuildinFileOptionField(_copyBuildinFileOptionField, _copyBuildinFileTagsField);
|
||||
|
||||
// 清理构建缓存
|
||||
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
@@ -94,14 +94,14 @@ namespace YooAsset.Editor
|
||||
protected virtual void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
var builtinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
var builtinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyParams(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, PipelineName);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, PipelineName);
|
||||
|
||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuiltinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildinFileRoot = 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.BuiltinFileCopyOption = builtinFileCopyOption;
|
||||
buildParameters.BuiltinFileCopyParams = builtinFileCopyParams;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
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 Builtin File Option" value="Center" name="CopyBuiltinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Builtin File Param" name="CopyBuiltinFileParam" />
|
||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Param" name="CopyBuildinFileParam" />
|
||||
<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 _copyBuiltinFileOptionField;
|
||||
protected TextField _copyBuiltinFileTagsField;
|
||||
protected EnumField _copyBuildinFileOptionField;
|
||||
protected TextField _copyBuildinFileTagsField;
|
||||
protected Toggle _clearBuildCacheToggle;
|
||||
protected Toggle _useAssetDependencyDBToggle;
|
||||
|
||||
@@ -60,13 +60,13 @@ namespace YooAsset.Editor
|
||||
SetOutputNameStyleField(_outputNameStyleField);
|
||||
|
||||
// 首包文件拷贝参数
|
||||
_copyBuiltinFileTagsField = Root.Q<TextField>("CopyBuiltinFileParam");
|
||||
SetCopyBuiltinFileTagsField(_copyBuiltinFileTagsField);
|
||||
SetCopyBuiltinFileTagsVisible(_copyBuiltinFileTagsField);
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
SetCopyBuildinFileTagsField(_copyBuildinFileTagsField);
|
||||
SetCopyBuildinFileTagsVisible(_copyBuildinFileTagsField);
|
||||
|
||||
// 首包文件拷贝选项
|
||||
_copyBuiltinFileOptionField = Root.Q<EnumField>("CopyBuiltinFileOption");
|
||||
SetCopyBuiltinFileOptionField(_copyBuiltinFileOptionField, _copyBuiltinFileTagsField);
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
SetCopyBuildinFileOptionField(_copyBuildinFileOptionField, _copyBuildinFileTagsField);
|
||||
|
||||
// 清理构建缓存
|
||||
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
@@ -99,15 +99,15 @@ namespace YooAsset.Editor
|
||||
protected virtual void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
var builtinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyOption(PackageName, PipelineName);
|
||||
var builtinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuiltinFileCopyParams(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(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.BuiltinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildinFileRoot = 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.BuiltinFileCopyOption = builtinFileCopyOption;
|
||||
buildParameters.BuiltinFileCopyParams = builtinFileCopyParams;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
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 Builtin File Option" value="Center" name="CopyBuiltinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Builtin File Param" name="CopyBuiltinFileParam" />
|
||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Param" name="CopyBuildinFileParam" />
|
||||
<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>
|
||||
|
||||
@@ -236,6 +236,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 包裹名称
|
||||
_packageNameTxt = root.Q<TextField>("PackageName");
|
||||
_packageNameTxt.isDelayed = true;
|
||||
_packageNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
@@ -249,6 +250,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 包裹备注
|
||||
_packageDescTxt = root.Q<TextField>("PackageDesc");
|
||||
_packageDescTxt.isDelayed = true;
|
||||
_packageDescTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
@@ -286,6 +288,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 分组名称
|
||||
_groupNameTxt = root.Q<TextField>("GroupName");
|
||||
_groupNameTxt.isDelayed = true;
|
||||
_groupNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
@@ -300,6 +303,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 分组备注
|
||||
_groupDescTxt = root.Q<TextField>("GroupDesc");
|
||||
_groupDescTxt.isDelayed = true;
|
||||
_groupDescTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
@@ -314,6 +318,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 分组的资源标签
|
||||
_groupTagsTxt = root.Q<TextField>("GroupTags");
|
||||
_groupTagsTxt.isDelayed = true;
|
||||
_groupTagsTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
@@ -817,6 +822,7 @@ namespace YooAsset.Editor
|
||||
var textField = new TextField();
|
||||
textField.name = "TextField0";
|
||||
textField.label = "User Data";
|
||||
textField.isDelayed = true;
|
||||
textField.style.width = 200;
|
||||
elementBottom.Add(textField);
|
||||
var label = textField.Q<Label>();
|
||||
@@ -826,6 +832,7 @@ namespace YooAsset.Editor
|
||||
var textField = new TextField();
|
||||
textField.name = "TextField1";
|
||||
textField.label = "Asset Tags";
|
||||
textField.isDelayed = true;
|
||||
textField.style.width = 100;
|
||||
textField.style.marginLeft = 20;
|
||||
textField.style.flexGrow = 1;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -53,24 +53,29 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 创建内置清单实例
|
||||
var builtinFileCatalog = new DefaultBuiltinFileCatalog();
|
||||
builtinFileCatalog.FileVersion = CatalogDefine.FileVersion;
|
||||
builtinFileCatalog.PackageName = packageName;
|
||||
builtinFileCatalog.PackageVersion = packageVersion;
|
||||
var buildinFileCatalog = new DefaultBuildinFileCatalog();
|
||||
buildinFileCatalog.FileVersion = CatalogDefine.FileVersion;
|
||||
buildinFileCatalog.PackageName = packageName;
|
||||
buildinFileCatalog.PackageVersion = packageVersion;
|
||||
|
||||
// 创建白名单查询集合
|
||||
HashSet<string> whiteFileList = new HashSet<string>
|
||||
{
|
||||
"link.xml",
|
||||
"buildlogtep.json",
|
||||
$"{packageName}.version",
|
||||
$"{packageName}_{packageVersion}.bytes",
|
||||
$"{packageName}_{packageVersion}.hash",
|
||||
$"{packageName}_{packageVersion}.json",
|
||||
$"{packageName}_{packageVersion}.report",
|
||||
DefaultBuiltinFileSystemDefine.BuiltinCatalogJsonFileName,
|
||||
DefaultBuiltinFileSystemDefine.BuiltinCatalogBinaryFileName
|
||||
DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName,
|
||||
DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName
|
||||
};
|
||||
string packageVersionFileName = YooAssetSettingsData.GetPackageVersionFileName(packageName);
|
||||
string packageHashFileName = YooAssetSettingsData.GetPackageHashFileName(packageName, packageVersion);
|
||||
string manifestBinaryFIleName = YooAssetSettingsData.GetManifestBinaryFileName(packageName, packageVersion);
|
||||
string manifestJsonFIleName = YooAssetSettingsData.GetManifestJsonFileName(packageName, packageVersion);
|
||||
string reportFileName = YooAssetSettingsData.GetBuildReportFileName(packageName, packageVersion);
|
||||
whiteFileList.Add(packageVersionFileName);
|
||||
whiteFileList.Add(packageHashFileName);
|
||||
whiteFileList.Add(manifestBinaryFIleName);
|
||||
whiteFileList.Add(manifestJsonFIleName);
|
||||
whiteFileList.Add(reportFileName);
|
||||
|
||||
// 记录所有内置资源文件
|
||||
DirectoryInfo rootDirectory = new DirectoryInfo(packageDirectory);
|
||||
@@ -86,10 +91,10 @@ namespace YooAsset
|
||||
string fileName = fileInfo.Name;
|
||||
if (fileMapping.TryGetValue(fileName, out string bundleGUID))
|
||||
{
|
||||
var wrapper = new DefaultBuiltinFileCatalog.FileWrapper();
|
||||
var wrapper = new DefaultBuildinFileCatalog.FileWrapper();
|
||||
wrapper.BundleGUID = bundleGUID;
|
||||
wrapper.FileName = fileName;
|
||||
builtinFileCatalog.Wrappers.Add(wrapper);
|
||||
buildinFileCatalog.Wrappers.Add(wrapper);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -98,16 +103,16 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 创建输出文件
|
||||
string jsonFilePath = $"{packageDirectory}/{DefaultBuiltinFileSystemDefine.BuiltinCatalogJsonFileName}";
|
||||
string jsonFilePath = $"{packageDirectory}/{DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName}";
|
||||
if (File.Exists(jsonFilePath))
|
||||
File.Delete(jsonFilePath);
|
||||
SerializeToJson(jsonFilePath, builtinFileCatalog);
|
||||
SerializeToJson(jsonFilePath, buildinFileCatalog);
|
||||
|
||||
// 创建输出文件
|
||||
string binaryFilePath = $"{packageDirectory}/{DefaultBuiltinFileSystemDefine.BuiltinCatalogBinaryFileName}";
|
||||
string binaryFilePath = $"{packageDirectory}/{DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName}";
|
||||
if (File.Exists(binaryFilePath))
|
||||
File.Delete(binaryFilePath);
|
||||
SerializeToBinary(binaryFilePath, builtinFileCatalog);
|
||||
SerializeToBinary(binaryFilePath, buildinFileCatalog);
|
||||
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
Debug.Log($"Succeed to save catalog file : {binaryFilePath}");
|
||||
@@ -118,7 +123,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 序列化(JSON文件)
|
||||
/// </summary>
|
||||
public static void SerializeToJson(string savePath, DefaultBuiltinFileCatalog catalog)
|
||||
public static void SerializeToJson(string savePath, DefaultBuildinFileCatalog catalog)
|
||||
{
|
||||
string json = JsonUtility.ToJson(catalog, true);
|
||||
FileUtility.WriteAllText(savePath, json);
|
||||
@@ -127,15 +132,15 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 反序列化(JSON文件)
|
||||
/// </summary>
|
||||
public static DefaultBuiltinFileCatalog DeserializeFromJson(string jsonContent)
|
||||
public static DefaultBuildinFileCatalog DeserializeFromJson(string jsonContent)
|
||||
{
|
||||
return JsonUtility.FromJson<DefaultBuiltinFileCatalog>(jsonContent);
|
||||
return JsonUtility.FromJson<DefaultBuildinFileCatalog>(jsonContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化(二进制文件)
|
||||
/// </summary>
|
||||
public static void SerializeToBinary(string savePath, DefaultBuiltinFileCatalog catalog)
|
||||
public static void SerializeToBinary(string savePath, DefaultBuildinFileCatalog catalog)
|
||||
{
|
||||
using (FileStream fs = new FileStream(savePath, FileMode.Create))
|
||||
{
|
||||
@@ -170,7 +175,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 反序列化(二进制文件)
|
||||
/// </summary>
|
||||
public static DefaultBuiltinFileCatalog DeserializeFromBinary(byte[] binaryData)
|
||||
public static DefaultBuildinFileCatalog DeserializeFromBinary(byte[] binaryData)
|
||||
{
|
||||
// 创建缓存器
|
||||
BufferReader buffer = new BufferReader(binaryData);
|
||||
@@ -185,7 +190,7 @@ namespace YooAsset
|
||||
if (fileVersion != CatalogDefine.FileVersion)
|
||||
throw new Exception($"The catalog file version are not compatible : {fileVersion} != {CatalogDefine.FileVersion}");
|
||||
|
||||
DefaultBuiltinFileCatalog catalog = new DefaultBuiltinFileCatalog();
|
||||
DefaultBuildinFileCatalog catalog = new DefaultBuildinFileCatalog();
|
||||
{
|
||||
// 读取文件头信息
|
||||
catalog.FileVersion = fileVersion;
|
||||
@@ -194,10 +199,10 @@ namespace YooAsset
|
||||
|
||||
// 读取资源包列表
|
||||
int fileCount = buffer.ReadInt32();
|
||||
catalog.Wrappers = new List<DefaultBuiltinFileCatalog.FileWrapper>(fileCount);
|
||||
catalog.Wrappers = new List<DefaultBuildinFileCatalog.FileWrapper>(fileCount);
|
||||
for (int i = 0; i < fileCount; i++)
|
||||
{
|
||||
var fileWrapper = new DefaultBuiltinFileCatalog.FileWrapper();
|
||||
var fileWrapper = new DefaultBuildinFileCatalog.FileWrapper();
|
||||
fileWrapper.BundleGUID = buffer.ReadUTF8();
|
||||
fileWrapper.FileName = buffer.ReadUTF8();
|
||||
catalog.Wrappers.Add(fileWrapper);
|
||||
@@ -8,7 +8,7 @@ namespace YooAsset
|
||||
/// 内置资源清单目录
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
internal class DefaultBuiltinFileCatalog
|
||||
internal class DefaultBuildinFileCatalog
|
||||
{
|
||||
[Serializable]
|
||||
public class FileWrapper
|
||||
@@ -8,7 +8,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 内置文件系统
|
||||
/// </summary>
|
||||
internal class DefaultBuiltinFileSystem : IFileSystem
|
||||
internal class DefaultBuildinFileSystem : 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> _builtinFilePathMapping = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _buildinFilePathMapping = new Dictionary<string, string>(10000);
|
||||
protected IFileSystem _unpackFileSystem;
|
||||
protected string _packageRoot;
|
||||
|
||||
@@ -81,13 +81,13 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 自定义参数:拷贝内置清单
|
||||
/// </summary>
|
||||
public bool CopyBuiltinPackageManifest { private set; get; } = false;
|
||||
public bool CopyBuildinPackageManifest { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:拷贝内置清单的目标目录
|
||||
/// 注意:该参数为空的时候,会获取默认的沙盒目录!
|
||||
/// </summary>
|
||||
public string CopyBuiltinPackageManifestDestRoot { private set; get; }
|
||||
public string CopyBuildinPackageManifestDestRoot { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:解密服务接口的实例类
|
||||
@@ -106,7 +106,7 @@ namespace YooAsset
|
||||
#endregion
|
||||
|
||||
|
||||
public DefaultBuiltinFileSystem()
|
||||
public DefaultBuildinFileSystem()
|
||||
{
|
||||
}
|
||||
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
||||
@@ -131,7 +131,7 @@ namespace YooAsset
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||
{
|
||||
// 注意:业务层的解压器会依赖该方法
|
||||
options.ImportFilePath = GetBuiltinFileLoadPath(bundle);
|
||||
options.ImportFilePath = GetBuildinFileLoadPath(bundle);
|
||||
return _unpackFileSystem.DownloadFileAsync(bundle, options);
|
||||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
@@ -153,7 +153,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
string error = $"{nameof(DefaultBuiltinFileSystem)} not support load bundle type : {bundle.BundleType}";
|
||||
string error = $"{nameof(DefaultBuildinFileSystem)} 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)
|
||||
{
|
||||
CopyBuiltinPackageManifest = Convert.ToBoolean(value);
|
||||
CopyBuildinPackageManifest = Convert.ToBoolean(value);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT)
|
||||
{
|
||||
CopyBuiltinPackageManifestDestRoot = (string)value;
|
||||
CopyBuildinPackageManifestDestRoot = (string)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||
{
|
||||
@@ -212,7 +212,7 @@ namespace YooAsset
|
||||
PackageName = packageName;
|
||||
|
||||
if (string.IsNullOrEmpty(packageRoot))
|
||||
_packageRoot = GetDefaultBuiltinPackageRoot(packageName);
|
||||
_packageRoot = GetDefaultBuildinPackageRoot(packageName);
|
||||
else
|
||||
_packageRoot = packageRoot;
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace YooAsset
|
||||
if (IsUnpackBundleFile(bundle))
|
||||
return _unpackFileSystem.GetBundleFilePath(bundle);
|
||||
|
||||
return GetBuiltinFileLoadPath(bundle);
|
||||
return GetBuildinFileLoadPath(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 builtin bundle file data !");
|
||||
YooLogger.Error($"Android platform not support read buildin bundle file data !");
|
||||
return null;
|
||||
#else
|
||||
if (bundle.Encrypted)
|
||||
@@ -292,7 +292,7 @@ namespace YooAsset
|
||||
return null;
|
||||
}
|
||||
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
@@ -303,7 +303,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
return FileUtility.ReadAllBytes(filePath);
|
||||
}
|
||||
#endif
|
||||
@@ -318,7 +318,7 @@ namespace YooAsset
|
||||
|
||||
#if UNITY_ANDROID
|
||||
//TODO : 安卓平台内置文件属于APK压缩包内的文件。
|
||||
YooLogger.Error($"Android platform not support read builtin bundle file text !");
|
||||
YooLogger.Error($"Android platform not support read buildin bundle file text !");
|
||||
return null;
|
||||
#else
|
||||
if (bundle.Encrypted)
|
||||
@@ -329,7 +329,7 @@ namespace YooAsset
|
||||
return null;
|
||||
}
|
||||
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
@@ -340,7 +340,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
return FileUtility.ReadAllText(filePath);
|
||||
}
|
||||
#endif
|
||||
@@ -368,38 +368,38 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
#region 内部方法
|
||||
protected string GetDefaultBuiltinPackageRoot(string packageName)
|
||||
protected string GetDefaultBuildinPackageRoot(string packageName)
|
||||
{
|
||||
string rootDirectory = YooAssetSettingsData.GetYooDefaultBuiltinRoot();
|
||||
string rootDirectory = YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||
return PathUtility.Combine(rootDirectory, packageName);
|
||||
}
|
||||
public string GetBuiltinFileLoadPath(PackageBundle bundle)
|
||||
public string GetBuildinFileLoadPath(PackageBundle bundle)
|
||||
{
|
||||
if (_builtinFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
if (_buildinFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
filePath = PathUtility.Combine(_packageRoot, bundle.FileName);
|
||||
_builtinFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
_buildinFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
public string GetBuiltinPackageVersionFilePath()
|
||||
public string GetBuildinPackageVersionFilePath()
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(PackageName);
|
||||
return PathUtility.Combine(_packageRoot, fileName);
|
||||
}
|
||||
public string GetBuiltinPackageHashFilePath(string packageVersion)
|
||||
public string GetBuildinPackageHashFilePath(string packageVersion)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(PackageName, packageVersion);
|
||||
return PathUtility.Combine(_packageRoot, fileName);
|
||||
}
|
||||
public string GetBuiltinPackageManifestFilePath(string packageVersion)
|
||||
public string GetBuildinPackageManifestFilePath(string packageVersion)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
||||
return PathUtility.Combine(_packageRoot, fileName);
|
||||
}
|
||||
public string GetCatalogBinaryFileLoadPath()
|
||||
{
|
||||
return PathUtility.Combine(_packageRoot, DefaultBuiltinFileSystemDefine.BuiltinCatalogBinaryFileName);
|
||||
return PathUtility.Combine(_packageRoot, DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -409,7 +409,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_wrappers.ContainsKey(bundleGUID))
|
||||
{
|
||||
YooLogger.Error($"{nameof(DefaultBuiltinFileSystem)} has element : {bundleGUID}");
|
||||
YooLogger.Error($"{nameof(DefaultBuildinFileSystem)} has element : {bundleGUID}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundle(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
@@ -445,7 +445,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundleAsync(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetBuiltinFileLoadPath(bundle);
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
@@ -1,16 +1,16 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DefaultBuiltinFileSystemDefine
|
||||
internal class DefaultBuildinFileSystemDefine
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置清单JSON文件名称
|
||||
/// </summary>
|
||||
public const string BuiltinCatalogJsonFileName = "BuiltinCatalog.json";
|
||||
public const string BuildinCatalogJsonFileName = "BuildinCatalog.json";
|
||||
|
||||
/// <summary>
|
||||
/// 内置清单二进制文件名称
|
||||
/// </summary>
|
||||
public const string BuiltinCatalogBinaryFileName = "BuiltinCatalog.bytes";
|
||||
public const string BuildinCatalogBinaryFileName = "BuildinCatalog.bytes";
|
||||
}
|
||||
}
|
||||
@@ -8,23 +8,23 @@ namespace YooAsset
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadBuiltinPackageVersion,
|
||||
CopyBuiltinPackageHash,
|
||||
CopyBuiltinPackageManifest,
|
||||
LoadBuildinPackageVersion,
|
||||
CopyBuildinPackageHash,
|
||||
CopyBuildinPackageManifest,
|
||||
InitUnpackFileSystem,
|
||||
LoadCatalogFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private RequestBuiltinPackageVersionOperation _requestBuiltinPackageVersionOp;
|
||||
private CopyBuiltinFileOperation _copyBuiltinHashFileOp;
|
||||
private CopyBuiltinFileOperation _copyBuiltinManifestFileOp;
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
|
||||
private CopyBuildinFileOperation _copyBuildinHashFileOp;
|
||||
private CopyBuildinFileOperation _copyBuildinManifestFileOp;
|
||||
private FSInitializeFileSystemOperation _initUnpackFIleSystemOp;
|
||||
private LoadBuiltinCatalogFileOperation _loadBuiltinCatalogFileOp;
|
||||
private LoadBuildinCatalogFileOperation _loadBuildinCatalogFileOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal DBFSInitializeOperation(DefaultBuiltinFileSystem fileSystem)
|
||||
internal DBFSInitializeOperation(DefaultBuildinFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
@@ -33,10 +33,10 @@ namespace YooAsset
|
||||
#if UNITY_WEBGL
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"{nameof(DefaultBuiltinFileSystem)} is not support WEBGL platform !";
|
||||
Error = $"{nameof(DefaultBuildinFileSystem)} is not support WEBGL platform !";
|
||||
#else
|
||||
if (_fileSystem.CopyBuiltinPackageManifest)
|
||||
_steps = ESteps.LoadBuiltinPackageVersion;
|
||||
if (_fileSystem.CopyBuildinPackageManifest)
|
||||
_steps = ESteps.LoadBuildinPackageVersion;
|
||||
else
|
||||
_steps = ESteps.InitUnpackFileSystem;
|
||||
#endif
|
||||
@@ -46,76 +46,76 @@ namespace YooAsset
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadBuiltinPackageVersion)
|
||||
if (_steps == ESteps.LoadBuildinPackageVersion)
|
||||
{
|
||||
if (_requestBuiltinPackageVersionOp == null)
|
||||
if (_requestBuildinPackageVersionOp == null)
|
||||
{
|
||||
_requestBuiltinPackageVersionOp = new RequestBuiltinPackageVersionOperation(_fileSystem);
|
||||
_requestBuiltinPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestBuiltinPackageVersionOp);
|
||||
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
|
||||
_requestBuildinPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestBuildinPackageVersionOp);
|
||||
}
|
||||
|
||||
_requestBuiltinPackageVersionOp.UpdateOperation();
|
||||
if (_requestBuiltinPackageVersionOp.IsDone == false)
|
||||
_requestBuildinPackageVersionOp.UpdateOperation();
|
||||
if (_requestBuildinPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_requestBuiltinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
if (_requestBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CopyBuiltinPackageHash;
|
||||
_steps = ESteps.CopyBuildinPackageHash;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _requestBuiltinPackageVersionOp.Error;
|
||||
Error = _requestBuildinPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CopyBuiltinPackageHash)
|
||||
if (_steps == ESteps.CopyBuildinPackageHash)
|
||||
{
|
||||
if (_copyBuiltinHashFileOp == null)
|
||||
if (_copyBuildinHashFileOp == null)
|
||||
{
|
||||
string packageVersion = _requestBuiltinPackageVersionOp.PackageVersion;
|
||||
string packageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||
string destFilePath = GetCopyPackageHashDestPath(packageVersion);
|
||||
string sourceFilePath = _fileSystem.GetBuiltinPackageHashFilePath(packageVersion);
|
||||
_copyBuiltinHashFileOp = new CopyBuiltinFileOperation(sourceFilePath, destFilePath);
|
||||
_copyBuiltinHashFileOp.StartOperation();
|
||||
AddChildOperation(_copyBuiltinHashFileOp);
|
||||
string sourceFilePath = _fileSystem.GetBuildinPackageHashFilePath(packageVersion);
|
||||
_copyBuildinHashFileOp = new CopyBuildinFileOperation(sourceFilePath, destFilePath);
|
||||
_copyBuildinHashFileOp.StartOperation();
|
||||
AddChildOperation(_copyBuildinHashFileOp);
|
||||
}
|
||||
|
||||
_copyBuiltinHashFileOp.UpdateOperation();
|
||||
if (_copyBuiltinHashFileOp.IsDone == false)
|
||||
_copyBuildinHashFileOp.UpdateOperation();
|
||||
if (_copyBuildinHashFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_copyBuiltinHashFileOp.Status == EOperationStatus.Succeed)
|
||||
if (_copyBuildinHashFileOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CopyBuiltinPackageManifest;
|
||||
_steps = ESteps.CopyBuildinPackageManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _copyBuiltinHashFileOp.Error;
|
||||
Error = _copyBuildinHashFileOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CopyBuiltinPackageManifest)
|
||||
if (_steps == ESteps.CopyBuildinPackageManifest)
|
||||
{
|
||||
if (_copyBuiltinManifestFileOp == null)
|
||||
if (_copyBuildinManifestFileOp == null)
|
||||
{
|
||||
string packageVersion = _requestBuiltinPackageVersionOp.PackageVersion;
|
||||
string packageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||
string destFilePath = GetCopyPackageManifestDestPath(packageVersion);
|
||||
string sourceFilePath = _fileSystem.GetBuiltinPackageManifestFilePath(packageVersion);
|
||||
_copyBuiltinManifestFileOp = new CopyBuiltinFileOperation(sourceFilePath, destFilePath);
|
||||
_copyBuiltinManifestFileOp.StartOperation();
|
||||
AddChildOperation(_copyBuiltinManifestFileOp);
|
||||
string sourceFilePath = _fileSystem.GetBuildinPackageManifestFilePath(packageVersion);
|
||||
_copyBuildinManifestFileOp = new CopyBuildinFileOperation(sourceFilePath, destFilePath);
|
||||
_copyBuildinManifestFileOp.StartOperation();
|
||||
AddChildOperation(_copyBuildinManifestFileOp);
|
||||
}
|
||||
|
||||
_copyBuiltinManifestFileOp.UpdateOperation();
|
||||
if (_copyBuiltinManifestFileOp.IsDone == false)
|
||||
_copyBuildinManifestFileOp.UpdateOperation();
|
||||
if (_copyBuildinManifestFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_copyBuiltinManifestFileOp.Status == EOperationStatus.Succeed)
|
||||
if (_copyBuildinManifestFileOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.InitUnpackFileSystem;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _copyBuiltinManifestFileOp.Error;
|
||||
Error = _copyBuildinManifestFileOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,20 +163,20 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.LoadCatalogFile)
|
||||
{
|
||||
if (_loadBuiltinCatalogFileOp == null)
|
||||
if (_loadBuildinCatalogFileOp == null)
|
||||
{
|
||||
_loadBuiltinCatalogFileOp = new LoadBuiltinCatalogFileOperation(_fileSystem);
|
||||
_loadBuiltinCatalogFileOp.StartOperation();
|
||||
AddChildOperation(_loadBuiltinCatalogFileOp);
|
||||
_loadBuildinCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
|
||||
_loadBuildinCatalogFileOp.StartOperation();
|
||||
AddChildOperation(_loadBuildinCatalogFileOp);
|
||||
}
|
||||
|
||||
_loadBuiltinCatalogFileOp.UpdateOperation();
|
||||
if (_loadBuiltinCatalogFileOp.IsDone == false)
|
||||
_loadBuildinCatalogFileOp.UpdateOperation();
|
||||
if (_loadBuildinCatalogFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadBuiltinCatalogFileOp.Status == EOperationStatus.Succeed)
|
||||
if (_loadBuildinCatalogFileOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
var catalog = _loadBuiltinCatalogFileOp.Catalog;
|
||||
var catalog = _loadBuildinCatalogFileOp.Catalog;
|
||||
if (catalog == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
@@ -195,11 +195,11 @@ namespace YooAsset
|
||||
|
||||
foreach (var wrapper in catalog.Wrappers)
|
||||
{
|
||||
var fileWrapper = new DefaultBuiltinFileSystem.FileWrapper(wrapper.FileName);
|
||||
var fileWrapper = new DefaultBuildinFileSystem.FileWrapper(wrapper.FileName);
|
||||
_fileSystem.RecordCatalogFile(wrapper.BundleGUID, fileWrapper);
|
||||
}
|
||||
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' builtin catalog files count : {catalog.Wrappers.Count}");
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' buildin 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 = _loadBuiltinCatalogFileOp.Error;
|
||||
Error = _loadBuildinCatalogFileOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetCopyManifestFileRoot()
|
||||
{
|
||||
string destRoot = _fileSystem.CopyBuiltinPackageManifestDestRoot;
|
||||
string destRoot = _fileSystem.CopyBuildinPackageManifestDestRoot;
|
||||
if (string.IsNullOrEmpty(destRoot))
|
||||
{
|
||||
string defaultCacheRoot = YooAssetSettingsData.GetYooDefaultCacheRoot();
|
||||
@@ -16,7 +16,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly PackageBundle _bundle;
|
||||
private AssetBundleCreateRequest _createRequest;
|
||||
private AssetBundle _assetBundle;
|
||||
@@ -24,7 +24,7 @@ namespace YooAsset
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DBFSLoadAssetBundleOperation(DefaultBuiltinFileSystem fileSystem, PackageBundle bundle)
|
||||
internal DBFSLoadAssetBundleOperation(DefaultBuildinFileSystem fileSystem, PackageBundle bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
@@ -64,7 +64,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = _fileSystem.GetBuiltinFileLoadPath(_bundle);
|
||||
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||
_assetBundle = AssetBundle.LoadFromFile(filePath);
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = _fileSystem.GetBuiltinFileLoadPath(_bundle);
|
||||
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||
_createRequest = AssetBundle.LoadFromFileAsync(filePath);
|
||||
}
|
||||
}
|
||||
@@ -110,14 +110,14 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Failed to load encrypted builtin asset bundle file : {_bundle.BundleName}";
|
||||
Error = $"Failed to load encrypted buildin asset bundle file : {_bundle.BundleName}";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Failed to load builtin asset bundle file : {_bundle.BundleName}";
|
||||
Error = $"Failed to load buildin asset bundle file : {_bundle.BundleName}";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
}
|
||||
@@ -150,16 +150,16 @@ namespace YooAsset
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadBuiltinRawBundle,
|
||||
LoadBuildinRawBundle,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly PackageBundle _bundle;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DBFSLoadRawBundleOperation(DefaultBuiltinFileSystem fileSystem, PackageBundle bundle)
|
||||
internal DBFSLoadRawBundleOperation(DefaultBuildinFileSystem fileSystem, PackageBundle bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
@@ -168,22 +168,22 @@ namespace YooAsset
|
||||
{
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
_steps = ESteps.LoadBuiltinRawBundle;
|
||||
_steps = ESteps.LoadBuildinRawBundle;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadBuiltinRawBundle)
|
||||
if (_steps == ESteps.LoadBuildinRawBundle)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuiltinFileLoadPath(_bundle);
|
||||
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||
|
||||
#if UNITY_ANDROID
|
||||
//TODO : 安卓平台内置文件属于APK压缩包内的文件。
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Can not load android builtin raw bundle file : {filePath}";
|
||||
Error = $"Can not load android buildin 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 builtin raw bundle file : {filePath}";
|
||||
Error = $"Can not found buildin raw bundle file : {filePath}";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,12 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private RequestBuiltinPackageVersionOperation _requestBuiltinPackageVersionOp;
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DBFSRequestPackageVersionOperation(DefaultBuiltinFileSystem fileSystem)
|
||||
internal DBFSRequestPackageVersionOperation(DefaultBuildinFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
@@ -30,28 +30,28 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.RequestPackageVersion)
|
||||
{
|
||||
if (_requestBuiltinPackageVersionOp == null)
|
||||
if (_requestBuildinPackageVersionOp == null)
|
||||
{
|
||||
_requestBuiltinPackageVersionOp = new RequestBuiltinPackageVersionOperation(_fileSystem);
|
||||
_requestBuiltinPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestBuiltinPackageVersionOp);
|
||||
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
|
||||
_requestBuildinPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestBuildinPackageVersionOp);
|
||||
}
|
||||
|
||||
_requestBuiltinPackageVersionOp.UpdateOperation();
|
||||
if (_requestBuiltinPackageVersionOp.IsDone == false)
|
||||
_requestBuildinPackageVersionOp.UpdateOperation();
|
||||
if (_requestBuildinPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_requestBuiltinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
if (_requestBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
PackageVersion = _requestBuiltinPackageVersionOp.PackageVersion;
|
||||
PackageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _requestBuiltinPackageVersionOp.Error;
|
||||
Error = _requestBuildinPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class CopyBuiltinFileOperation : AsyncOperationBase
|
||||
internal class CopyBuildinFileOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace YooAsset
|
||||
private readonly string _destFilePath;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public CopyBuiltinFileOperation(string sourceFilePath, string destFilePath)
|
||||
public CopyBuildinFileOperation(string sourceFilePath, string destFilePath)
|
||||
{
|
||||
_sourceFilePath = sourceFilePath;
|
||||
_destFilePath = destFilePath;
|
||||
@@ -61,7 +61,7 @@ namespace YooAsset
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
YooLogger.Warning($"Failed copy builtin file : {ex.Message}");
|
||||
YooLogger.Warning($"Failed copy buildin file : {ex.Message}");
|
||||
_steps = ESteps.UnpackFile;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class LoadBuiltinCatalogFileOperation : AsyncOperationBase
|
||||
internal sealed class LoadBuildinCatalogFileOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -14,7 +14,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||
private byte[] _fileData;
|
||||
private ESteps _steps = ESteps.None;
|
||||
@@ -22,9 +22,9 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 内置资源目录
|
||||
/// </summary>
|
||||
public DefaultBuiltinFileCatalog Catalog;
|
||||
public DefaultBuildinFileCatalog Catalog;
|
||||
|
||||
internal LoadBuiltinCatalogFileOperation(DefaultBuiltinFileSystem fileSystem)
|
||||
internal LoadBuildinCatalogFileOperation(DefaultBuildinFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class LoadBuiltinPackageManifestOperation : AsyncOperationBase
|
||||
internal class LoadBuildinPackageManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -14,7 +14,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private readonly DefaultBuildinFileSystem _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 LoadBuiltinPackageManifestOperation(DefaultBuiltinFileSystem fileSystem, string packageVersion, string packageHash)
|
||||
internal LoadBuildinPackageManifestOperation(DefaultBuildinFileSystem fileSystem, string packageVersion, string packageHash)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
@@ -45,7 +45,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.TryLoadFileData)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuiltinPackageManifestFilePath(_packageVersion);
|
||||
string filePath = _fileSystem.GetBuildinPackageManifestFilePath(_packageVersion);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
_fileData = File.ReadAllBytes(filePath);
|
||||
@@ -61,7 +61,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_webDataRequestOp == null)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuiltinPackageManifestFilePath(_packageVersion);
|
||||
string filePath = _fileSystem.GetBuildinPackageManifestFilePath(_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 builtin package manifest file !";
|
||||
Error = "Failed to verify buildin package manifest file !";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class RequestBuiltinPackageHashOperation : AsyncOperationBase
|
||||
internal class RequestBuildinPackageHashOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private readonly DefaultBuildinFileSystem _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 RequestBuiltinPackageHashOperation(DefaultBuiltinFileSystem fileSystem, string packageVersion)
|
||||
internal RequestBuildinPackageHashOperation(DefaultBuildinFileSystem fileSystem, string packageVersion)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
@@ -40,7 +40,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.TryLoadPackageHash)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuiltinPackageHashFilePath(_packageVersion);
|
||||
string filePath = _fileSystem.GetBuildinPackageHashFilePath(_packageVersion);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
PackageHash = File.ReadAllText(filePath);
|
||||
@@ -56,7 +56,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_webTextRequestOp == null)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuiltinPackageHashFilePath(_packageVersion);
|
||||
string filePath = _fileSystem.GetBuildinPackageHashFilePath(_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 = $"Builtin package hash file content is empty !";
|
||||
Error = $"Buildin package hash file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class RequestBuiltinPackageVersionOperation : AsyncOperationBase
|
||||
internal class RequestBuildinPackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuiltinFileSystem _fileSystem;
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace YooAsset
|
||||
public string PackageVersion { private set; get; }
|
||||
|
||||
|
||||
internal RequestBuiltinPackageVersionOperation(DefaultBuiltinFileSystem fileSystem)
|
||||
internal RequestBuildinPackageVersionOperation(DefaultBuildinFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.TryLoadPackageVersion)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuiltinPackageVersionFilePath();
|
||||
string filePath = _fileSystem.GetBuildinPackageVersionFilePath();
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
PackageVersion = File.ReadAllText(filePath);
|
||||
@@ -54,7 +54,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_webTextRequestOp == null)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuiltinPackageVersionFilePath();
|
||||
string filePath = _fileSystem.GetBuildinPackageVersionFilePath();
|
||||
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 = $"Builtin package version file content is empty !";
|
||||
Error = $"Buildin package version file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1,89 +0,0 @@
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ namespace YooAsset
|
||||
None,
|
||||
CheckExist,
|
||||
DownloadFile,
|
||||
AbortDownload,
|
||||
LoadAssetBundle,
|
||||
CheckResult,
|
||||
Done,
|
||||
@@ -63,6 +64,17 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
// 中断下载
|
||||
if (AbortDownloadFile)
|
||||
{
|
||||
if (_downloadFileOp != null)
|
||||
_downloadFileOp.AbortOperation();
|
||||
_steps = ESteps.AbortDownload;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
if (_downloadFileOp == null)
|
||||
@@ -94,6 +106,23 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.AbortDownload)
|
||||
{
|
||||
if (_downloadFileOp != null)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
_downloadFileOp.WaitForAsyncComplete();
|
||||
|
||||
_downloadFileOp.UpdateOperation();
|
||||
if (_downloadFileOp.IsDone == false)
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Abort download file !";
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadAssetBundle)
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
@@ -251,6 +280,7 @@ namespace YooAsset
|
||||
None,
|
||||
CheckExist,
|
||||
DownloadFile,
|
||||
AbortDownload,
|
||||
LoadCacheRawBundle,
|
||||
Done,
|
||||
}
|
||||
@@ -310,6 +340,17 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
// 中断下载
|
||||
if (AbortDownloadFile)
|
||||
{
|
||||
if (_downloadFileOp != null)
|
||||
_downloadFileOp.AbortOperation();
|
||||
_steps = ESteps.AbortDownload;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
if (_downloadFileOp == null)
|
||||
@@ -341,6 +382,23 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.AbortDownload)
|
||||
{
|
||||
if (_downloadFileOp != null)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
_downloadFileOp.WaitForAsyncComplete();
|
||||
|
||||
_downloadFileOp.UpdateOperation();
|
||||
if (_downloadFileOp.IsDone == false)
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Abort download file !";
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadCacheRawBundle)
|
||||
{
|
||||
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
private readonly DefaultCacheFileSystem _fileSystem;
|
||||
private IEnumerator<DirectoryInfo> _filesEnumerator = null;
|
||||
private IEnumerator<string> _filesEnumerator = null;
|
||||
private float _verifyStartTime;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
@@ -42,11 +42,11 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.Prepare)
|
||||
{
|
||||
DirectoryInfo rootDirectory = new DirectoryInfo(_fileSystem.GetCacheBundleFilesRoot());
|
||||
if (rootDirectory.Exists)
|
||||
string rootDirectory = _fileSystem.GetCacheBundleFilesRoot();
|
||||
if (Directory.Exists(rootDirectory))
|
||||
{
|
||||
var directorieInfos = rootDirectory.EnumerateDirectories();
|
||||
_filesEnumerator = directorieInfos.GetEnumerator();
|
||||
var directories = Directory.EnumerateDirectories(rootDirectory);
|
||||
_filesEnumerator = directories.GetEnumerator();
|
||||
}
|
||||
_steps = ESteps.SearchFiles;
|
||||
}
|
||||
@@ -76,15 +76,15 @@ namespace YooAsset
|
||||
break;
|
||||
|
||||
var rootFoder = _filesEnumerator.Current;
|
||||
var childDirectories = rootFoder.GetDirectories();
|
||||
var childDirectories = Directory.EnumerateDirectories(rootFoder);
|
||||
foreach (var chidDirectory in childDirectories)
|
||||
{
|
||||
string bundleGUID = chidDirectory.Name;
|
||||
string bundleGUID = Path.GetFileName(chidDirectory);
|
||||
if (_fileSystem.IsRecordBundleFile(bundleGUID))
|
||||
continue;
|
||||
|
||||
// 创建验证元素类
|
||||
string fileRootPath = chidDirectory.FullName;
|
||||
string fileRootPath = chidDirectory;
|
||||
string dataFilePath = $"{fileRootPath}/{DefaultCacheFileSystemDefine.BundleDataFileName}";
|
||||
string infoFilePath = $"{fileRootPath}/{DefaultCacheFileSystemDefine.BundleInfoFileName}";
|
||||
|
||||
@@ -108,17 +108,15 @@ namespace YooAsset
|
||||
|
||||
return isFindItem;
|
||||
}
|
||||
private string FindDataFileExtension(DirectoryInfo directoryInfo)
|
||||
private string FindDataFileExtension(string directory)
|
||||
{
|
||||
string dataFileExtension = string.Empty;
|
||||
var fileInfos = directoryInfo.GetFiles();
|
||||
foreach (var fileInfo in fileInfos)
|
||||
string searchPattern = DefaultCacheFileSystemDefine.BundleDataFileName + "*";
|
||||
var dataFiles = Directory.EnumerateFiles(directory, searchPattern);
|
||||
foreach (var filePath in dataFiles)
|
||||
{
|
||||
if (fileInfo.Name.StartsWith(DefaultCacheFileSystemDefine.BundleDataFileName))
|
||||
{
|
||||
dataFileExtension = fileInfo.Extension;
|
||||
break;
|
||||
}
|
||||
dataFileExtension = Path.GetExtension(filePath);
|
||||
break;
|
||||
}
|
||||
return dataFileExtension;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace YooAsset
|
||||
None,
|
||||
CheckExist,
|
||||
DownloadFile,
|
||||
AbortDownload,
|
||||
LoadAssetBundle,
|
||||
CheckResult,
|
||||
Done,
|
||||
@@ -48,6 +49,17 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
// 中断下载
|
||||
if (AbortDownloadFile)
|
||||
{
|
||||
if (_downloadFileOp != null)
|
||||
_downloadFileOp.AbortOperation();
|
||||
_steps = ESteps.AbortDownload;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
if (_downloadFileOp == null)
|
||||
@@ -79,6 +91,23 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.AbortDownload)
|
||||
{
|
||||
if (_downloadFileOp != null)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
_downloadFileOp.WaitForAsyncComplete();
|
||||
|
||||
_downloadFileOp.UpdateOperation();
|
||||
if (_downloadFileOp.IsDone == false)
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Abort download file !";
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadAssetBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
|
||||
@@ -4,12 +4,12 @@ namespace YooAsset
|
||||
{
|
||||
internal class DefaultUnpackRemoteServices : IRemoteServices
|
||||
{
|
||||
private readonly string _builtinPackageRoot;
|
||||
private readonly string _buildinPackageRoot;
|
||||
protected readonly Dictionary<string, string> _mapping = new Dictionary<string, string>(10000);
|
||||
|
||||
public DefaultUnpackRemoteServices(string builtinPackRoot)
|
||||
public DefaultUnpackRemoteServices(string buildinPackRoot)
|
||||
{
|
||||
_builtinPackageRoot = builtinPackRoot;
|
||||
_buildinPackageRoot = buildinPackRoot;
|
||||
}
|
||||
string IRemoteServices.GetRemoteMainURL(string fileName)
|
||||
{
|
||||
@@ -24,7 +24,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_mapping.TryGetValue(fileName, out string url) == false)
|
||||
{
|
||||
string filePath = PathUtility.Combine(_builtinPackageRoot, fileName);
|
||||
string filePath = PathUtility.Combine(_buildinPackageRoot, fileName);
|
||||
url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_mapping.Add(fileName, url);
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace YooAsset
|
||||
#region 内部方法
|
||||
protected string GetDefaultWebPackageRoot(string packageName)
|
||||
{
|
||||
string rootDirectory = YooAssetSettingsData.GetYooDefaultBuiltinRoot();
|
||||
string rootDirectory = YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||
return PathUtility.Combine(rootDirectory, packageName);
|
||||
}
|
||||
public string GetWebFileLoadPath(PackageBundle bundle)
|
||||
@@ -209,7 +209,7 @@ namespace YooAsset
|
||||
}
|
||||
public string GetCatalogBinaryFileLoadPath()
|
||||
{
|
||||
return PathUtility.Combine(_webPackageRoot, DefaultBuiltinFileSystemDefine.BuiltinCatalogBinaryFileName);
|
||||
return PathUtility.Combine(_webPackageRoot, DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace YooAsset
|
||||
_fileSystem.RecordCatalogFile(wrapper.BundleGUID, fileWrapper);
|
||||
}
|
||||
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' builtin catalog files count : {catalog.Wrappers.Count}");
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' buildin catalog files count : {catalog.Wrappers.Count}");
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
|
||||
@@ -83,9 +83,9 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||
/// <param name="packageRoot">文件系统的根目录</param>
|
||||
public static FileSystemParameters CreateDefaultBuiltinFileSystemParameters(IDecryptionServices decryptionServices = null, string packageRoot = null)
|
||||
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices = null, string packageRoot = null)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultBuiltinFileSystem).FullName;
|
||||
string fileSystemClass = typeof(DefaultBuildinFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||
return fileSystemParams;
|
||||
|
||||
@@ -17,6 +17,11 @@ namespace YooAsset
|
||||
/// 下载大小
|
||||
/// </summary>
|
||||
public long DownloadedBytes { protected set; get; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 终止下载文件
|
||||
/// </summary>
|
||||
public bool AbortDownloadFile = false;
|
||||
}
|
||||
|
||||
internal sealed class FSLoadBundleCompleteOperation : FSLoadBundleOperation
|
||||
|
||||
@@ -43,6 +43,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public int BundleLoadingMaxConcurrency = int.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 当资源引用计数为零的时候自动释放资源包
|
||||
/// </summary>
|
||||
public bool AutoUnloadBundleWhenUnused = false;
|
||||
|
||||
/// <summary>
|
||||
/// WebGL平台强制同步加载资源对象
|
||||
/// </summary>
|
||||
@@ -71,7 +76,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public class OfflinePlayModeParameters : InitializeParameters
|
||||
{
|
||||
public FileSystemParameters BuiltinFileSystemParameters;
|
||||
public FileSystemParameters BuildinFileSystemParameters;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -79,7 +84,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public class HostPlayModeParameters : InitializeParameters
|
||||
{
|
||||
public FileSystemParameters BuiltinFileSystemParameters;
|
||||
public FileSystemParameters BuildinFileSystemParameters;
|
||||
public FileSystemParameters CacheFileSystemParameters;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@ namespace YooAsset
|
||||
if (IsValidWithWarning == false)
|
||||
return;
|
||||
Provider.ReleaseHandle(this);
|
||||
|
||||
// 主动卸载零引用的资源包
|
||||
if (Provider.RefCount == 0)
|
||||
Provider.TryUnloadBundle();
|
||||
|
||||
Provider = null;
|
||||
}
|
||||
|
||||
@@ -146,11 +151,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public System.Threading.Tasks.Task Task
|
||||
{
|
||||
get
|
||||
get
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return null;
|
||||
return Provider.Task;
|
||||
return Provider.Task;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,6 +173,13 @@ namespace YooAsset
|
||||
|
||||
if (Result != null)
|
||||
Result.UnloadBundleFile();
|
||||
|
||||
if (IsDone == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Bundle loader destroyed !";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -180,11 +187,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public bool CanDestroyLoader()
|
||||
{
|
||||
// 注意:正在加载中的任务不可以销毁
|
||||
if (_steps == ESteps.LoadBundleFile)
|
||||
return false;
|
||||
|
||||
if (RefCount > 0)
|
||||
if (CanReleasableLoader() == false)
|
||||
return false;
|
||||
|
||||
// YOOASSET_LEGACY_DEPENDENCY
|
||||
@@ -194,14 +197,34 @@ namespace YooAsset
|
||||
{
|
||||
foreach (var bundleID in LoadBundleInfo.Bundle.ReferenceBundleIDs)
|
||||
{
|
||||
#if YOOASSET_EXPERIMENTAL
|
||||
if (_resManager.CheckBundleReleasable(bundleID) == false)
|
||||
return false;
|
||||
#else
|
||||
if (_resManager.CheckBundleDestroyed(bundleID) == false)
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否可以释放
|
||||
/// </summary>
|
||||
public bool CanReleasableLoader()
|
||||
{
|
||||
// 注意:正在加载中的任务不可以销毁
|
||||
if (_steps == ESteps.LoadBundleFile)
|
||||
return false;
|
||||
|
||||
if (RefCount > 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加附属的资源提供者
|
||||
/// </summary>
|
||||
@@ -240,5 +263,28 @@ namespace YooAsset
|
||||
_removeList.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试终止加载器
|
||||
/// </summary>
|
||||
public void TryAbortLoader()
|
||||
{
|
||||
if (IsDone == false)
|
||||
{
|
||||
if (_steps == ESteps.CheckConcurrency)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Abort bundle loader !";
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadBundleFile)
|
||||
{
|
||||
// 注意:终止下载器
|
||||
if (_loadBundleOp != null)
|
||||
_loadBundleOp.AbortDownloadFile = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ namespace YooAsset
|
||||
None,
|
||||
CheckOptions,
|
||||
ReleaseAll,
|
||||
AbortDownload,
|
||||
TryAbortLoader,
|
||||
CheckLoading,
|
||||
DestroyAll,
|
||||
Done,
|
||||
@@ -78,15 +78,16 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
_steps = ESteps.AbortDownload;
|
||||
_steps = ESteps.TryAbortLoader;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.AbortDownload)
|
||||
if (_steps == ESteps.TryAbortLoader)
|
||||
{
|
||||
// 注意:终止所有下载任务
|
||||
// 尝试终止所有加载任务
|
||||
// 注意:正在加载AssetBundle的任务无法终止
|
||||
foreach (var loader in _resManager.LoaderDic.Values)
|
||||
{
|
||||
loader.AbortOperation();
|
||||
loader.TryAbortLoader();
|
||||
}
|
||||
_steps = ESteps.CheckLoading;
|
||||
}
|
||||
|
||||
@@ -308,6 +308,17 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试卸载资源包
|
||||
/// </summary>
|
||||
public void TryUnloadBundle()
|
||||
{
|
||||
if (_resManager.AutoUnloadBundleWhenUnused)
|
||||
{
|
||||
_resManager.TryUnloadUnusedAsset(MainAssetInfo, 10);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 结束流程
|
||||
/// </summary>
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace YooAsset
|
||||
private int _bundleLoadingMaxConcurrency;
|
||||
|
||||
// 开发者配置选项
|
||||
public bool AutoUnloadBundleWhenUnused { private set; get; }
|
||||
public bool WebGLForceSyncLoadAsset { private set; get; }
|
||||
public bool UseWeakReferenceHandle { private set; get; }
|
||||
|
||||
@@ -47,6 +48,7 @@ namespace YooAsset
|
||||
public void Initialize(InitializeParameters parameters, IBundleQuery bundleServices)
|
||||
{
|
||||
_bundleLoadingMaxConcurrency = parameters.BundleLoadingMaxConcurrency;
|
||||
AutoUnloadBundleWhenUnused = parameters.AutoUnloadBundleWhenUnused;
|
||||
WebGLForceSyncLoadAsset = parameters.WebGLForceSyncLoadAsset;
|
||||
UseWeakReferenceHandle = parameters.UseWeakReferenceHandle;
|
||||
_bundleQuery = bundleServices;
|
||||
@@ -327,6 +329,14 @@ namespace YooAsset
|
||||
return true;
|
||||
return bundleFileLoader.IsDestroyed;
|
||||
}
|
||||
internal bool CheckBundleReleasable(int bundleID)
|
||||
{
|
||||
string bundleName = _bundleQuery.GetMainBundleName(bundleID);
|
||||
var bundleFileLoader = TryGetBundleFileLoader(bundleName);
|
||||
if (bundleFileLoader == null)
|
||||
return true;
|
||||
return bundleFileLoader.CanReleasableLoader();
|
||||
}
|
||||
internal bool HasAnyLoader()
|
||||
{
|
||||
return LoaderDic.Count > 0;
|
||||
|
||||
@@ -16,6 +16,13 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 文件格式版本
|
||||
/// </summary>
|
||||
public const string FileVersion = "2025.8.28";
|
||||
public const string FileVersion = "2025.9.30";
|
||||
public const string VERSION_2025_8_28 = "2025.8.28";
|
||||
public const string VERSION_2025_9_30 = "2025.9.30";
|
||||
|
||||
/// <summary>
|
||||
/// 版本兼容
|
||||
/// </summary>
|
||||
public const bool BackwardCompatible = true;
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,7 @@ namespace YooAsset
|
||||
buffer.WriteBool(manifest.SupportExtensionless);
|
||||
buffer.WriteBool(manifest.LocationToLower);
|
||||
buffer.WriteBool(manifest.IncludeAssetGUID);
|
||||
buffer.WriteBool(manifest.ReplaceAssetPathWithAddress);
|
||||
buffer.WriteInt32(manifest.OutputNameStyle);
|
||||
buffer.WriteInt32(manifest.BuildBundleType);
|
||||
buffer.WriteUTF8(manifest.BuildPipeline);
|
||||
@@ -129,7 +130,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 初始化资源清单
|
||||
InitManifest(manifest);
|
||||
manifest.Initialize();
|
||||
return manifest;
|
||||
}
|
||||
|
||||
@@ -144,38 +145,6 @@ namespace YooAsset
|
||||
return operation.Manifest;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源清单
|
||||
/// </summary>
|
||||
public static void InitManifest(PackageManifest manifest)
|
||||
{
|
||||
// 填充资源包内包含的主资源列表
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
int bundleID = packageAsset.BundleID;
|
||||
if (bundleID >= 0 && bundleID < manifest.BundleList.Count)
|
||||
{
|
||||
var packageBundle = manifest.BundleList[bundleID];
|
||||
packageBundle.IncludeMainAssets.Add(packageAsset);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid bundle id : {bundleID} Asset path : {packageAsset.AssetPath}");
|
||||
}
|
||||
}
|
||||
|
||||
// 填充资源包引用关系
|
||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
{
|
||||
var sourceBundle = manifest.BundleList[index];
|
||||
foreach (int dependIndex in sourceBundle.DependBundleIDs)
|
||||
{
|
||||
var dependBundle = manifest.BundleList[dependIndex];
|
||||
dependBundle.AddReferenceBundleID(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源文件的后缀名
|
||||
/// </summary>
|
||||
|
||||
@@ -13,13 +13,15 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
private readonly ResourcePackage _resourcePackage;
|
||||
private readonly UnloadAllAssetsOptions _options;
|
||||
private UnloadAllAssetsOperation _unloadAllAssetsOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
public DestroyOperation(ResourcePackage resourcePackage)
|
||||
public DestroyOperation(ResourcePackage resourcePackage, UnloadAllAssetsOptions options)
|
||||
{
|
||||
_resourcePackage = resourcePackage;
|
||||
_options = options;
|
||||
}
|
||||
|
||||
internal override void InternalStart()
|
||||
@@ -64,7 +66,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_unloadAllAssetsOp == null)
|
||||
{
|
||||
_unloadAllAssetsOp = _resourcePackage.UnloadAllAssetsAsync();
|
||||
_unloadAllAssetsOp = _resourcePackage.UnloadAllAssetsAsync(_options);
|
||||
_unloadAllAssetsOp.StartOperation();
|
||||
AddChildOperation(_unloadAllAssetsOp);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,10 @@ namespace YooAsset
|
||||
|
||||
// 读取文件版本
|
||||
string fileVersion = _buffer.ReadUTF8();
|
||||
if (fileVersion != ManifestDefine.FileVersion)
|
||||
Version fileVer = new Version(fileVersion);
|
||||
Version ver2025_8_28 = new Version(ManifestDefine.VERSION_2025_8_28);
|
||||
Version ver2025_9_30 = new Version(ManifestDefine.VERSION_2025_9_30);
|
||||
if (fileVer < ver2025_8_28)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
@@ -99,6 +102,10 @@ namespace YooAsset
|
||||
Manifest.SupportExtensionless = _buffer.ReadBool();
|
||||
Manifest.LocationToLower = _buffer.ReadBool();
|
||||
Manifest.IncludeAssetGUID = _buffer.ReadBool();
|
||||
if (fileVer >= ver2025_9_30)
|
||||
Manifest.ReplaceAssetPathWithAddress = _buffer.ReadBool();
|
||||
else
|
||||
Manifest.ReplaceAssetPathWithAddress = false;
|
||||
Manifest.OutputNameStyle = _buffer.ReadInt32();
|
||||
Manifest.BuildBundleType = _buffer.ReadInt32();
|
||||
Manifest.BuildPipeline = _buffer.ReadUTF8();
|
||||
@@ -109,6 +116,8 @@ namespace YooAsset
|
||||
// 检测配置
|
||||
if (Manifest.EnableAddressable && Manifest.LocationToLower)
|
||||
throw new System.Exception("Addressable not support location to lower !");
|
||||
if (Manifest.EnableAddressable == false && Manifest.ReplaceAssetPathWithAddress)
|
||||
throw new System.Exception("Replace asset path with address need enable Addressable !");
|
||||
|
||||
_steps = ESteps.PrepareAssetList;
|
||||
}
|
||||
@@ -122,21 +131,39 @@ namespace YooAsset
|
||||
}
|
||||
if (_steps == ESteps.DeserializeAssetList)
|
||||
{
|
||||
bool replaceAssetPath = false;
|
||||
if (UnityEngine.Application.isPlaying)
|
||||
{
|
||||
if (Manifest.EnableAddressable && Manifest.ReplaceAssetPathWithAddress)
|
||||
replaceAssetPath = true;
|
||||
}
|
||||
|
||||
while (_packageAssetCount > 0)
|
||||
{
|
||||
var packageAsset = new PackageAsset();
|
||||
packageAsset.Address = _buffer.ReadUTF8();
|
||||
packageAsset.AssetPath = _buffer.ReadUTF8();
|
||||
if (replaceAssetPath)
|
||||
{
|
||||
packageAsset.AssetPath = packageAsset.Address;
|
||||
_buffer.SkipUTF8(); //跳过解析AssetPath
|
||||
}
|
||||
else
|
||||
{
|
||||
packageAsset.AssetPath = _buffer.ReadUTF8();
|
||||
}
|
||||
packageAsset.AssetGUID = _buffer.ReadUTF8();
|
||||
packageAsset.AssetTags = _buffer.ReadUTF8Array();
|
||||
packageAsset.BundleID = _buffer.ReadInt32();
|
||||
packageAsset.DependBundleIDs = _buffer.ReadInt32Array();
|
||||
FillAssetCollection(Manifest, packageAsset);
|
||||
FillAssetCollection(Manifest, packageAsset, replaceAssetPath);
|
||||
|
||||
_packageAssetCount--;
|
||||
Progress = 1f - _packageAssetCount / _progressTotalValue;
|
||||
if (OperationSystem.IsBusy)
|
||||
break;
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
{
|
||||
if (OperationSystem.IsBusy)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_packageAssetCount <= 0)
|
||||
@@ -169,8 +196,11 @@ namespace YooAsset
|
||||
|
||||
_packageBundleCount--;
|
||||
Progress = 1f - _packageBundleCount / _progressTotalValue;
|
||||
if (OperationSystem.IsBusy)
|
||||
break;
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
{
|
||||
if (OperationSystem.IsBusy)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_packageBundleCount <= 0)
|
||||
@@ -181,7 +211,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.InitManifest)
|
||||
{
|
||||
ManifestTools.InitManifest(Manifest);
|
||||
Manifest.Initialize();
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
@@ -228,7 +258,7 @@ namespace YooAsset
|
||||
else
|
||||
manifest.AssetPathMapping2 = new Dictionary<string, string>();
|
||||
}
|
||||
private void FillAssetCollection(PackageManifest manifest, PackageAsset packageAsset)
|
||||
private void FillAssetCollection(PackageManifest manifest, PackageAsset packageAsset, bool replaceAssetPath)
|
||||
{
|
||||
// 添加到列表集合
|
||||
manifest.AssetList.Add(packageAsset);
|
||||
@@ -274,7 +304,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 添加可寻址地址
|
||||
if (manifest.EnableAddressable)
|
||||
if (manifest.EnableAddressable && replaceAssetPath == false)
|
||||
{
|
||||
string location = packageAsset.Address;
|
||||
if (string.IsNullOrEmpty(location) == false)
|
||||
|
||||
@@ -28,6 +28,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public bool IncludeAssetGUID;
|
||||
|
||||
/// <summary>
|
||||
/// 使用可寻址地址代替资源路径
|
||||
/// </summary>
|
||||
public bool ReplaceAssetPathWithAddress;
|
||||
|
||||
/// <summary>
|
||||
/// 文件名称样式
|
||||
/// </summary>
|
||||
|
||||
@@ -36,6 +36,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public bool IncludeAssetGUID;
|
||||
|
||||
/// <summary>
|
||||
/// 使用可寻址地址代替资源路径
|
||||
/// </summary>
|
||||
public bool ReplaceAssetPathWithAddress;
|
||||
|
||||
/// <summary>
|
||||
/// 文件名称样式
|
||||
/// </summary>
|
||||
@@ -113,6 +118,38 @@ namespace YooAsset
|
||||
public Dictionary<string, PackageBundle> BundleDic3;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源清单
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
// 填充资源包内包含的主资源列表
|
||||
foreach (var packageAsset in AssetList)
|
||||
{
|
||||
int bundleID = packageAsset.BundleID;
|
||||
if (bundleID >= 0 && bundleID < BundleList.Count)
|
||||
{
|
||||
var packageBundle = BundleList[bundleID];
|
||||
packageBundle.IncludeMainAssets.Add(packageAsset);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid bundle id : {bundleID} Asset path : {packageAsset.AssetPath}");
|
||||
}
|
||||
}
|
||||
|
||||
// 填充资源包引用关系
|
||||
for (int index = 0; index < BundleList.Count; index++)
|
||||
{
|
||||
var sourceBundle = BundleList[index];
|
||||
foreach (int dependIndex in sourceBundle.DependBundleIDs)
|
||||
{
|
||||
var dependBundle = BundleList[dependIndex];
|
||||
dependBundle.AddReferenceBundleID(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取包裹的详细信息
|
||||
/// </summary>
|
||||
@@ -124,6 +161,7 @@ namespace YooAsset
|
||||
details.SupportExtensionless = SupportExtensionless;
|
||||
details.LocationToLower = LocationToLower;
|
||||
details.IncludeAssetGUID = IncludeAssetGUID;
|
||||
details.ReplaceAssetPathWithAddress = ReplaceAssetPathWithAddress;
|
||||
details.OutputNameStyle = OutputNameStyle;
|
||||
details.BuildBundleType = BuildBundleType;
|
||||
details.BuildPipeline = BuildPipeline;
|
||||
|
||||
@@ -112,12 +112,12 @@ namespace YooAsset
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
var initializeParameters = parameters as OfflinePlayModeParameters;
|
||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.BuiltinFileSystemParameters);
|
||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters);
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
var initializeParameters = parameters as HostPlayModeParameters;
|
||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.BuiltinFileSystemParameters, initializeParameters.CacheFileSystemParameters);
|
||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters, initializeParameters.CacheFileSystemParameters);
|
||||
}
|
||||
else if (_playMode == EPlayMode.WebPlayMode)
|
||||
{
|
||||
@@ -209,7 +209,10 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public DestroyOperation DestroyAsync()
|
||||
{
|
||||
var operation = new DestroyOperation(this);
|
||||
var options = new UnloadAllAssetsOptions();
|
||||
options.ReleaseAllHandles = true;
|
||||
options.LockLoadOperation = true;
|
||||
var operation = new DestroyOperation(this, options);
|
||||
OperationSystem.StartOperation(null, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user