mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-24 17:50:15 +00:00
feat #643
This commit is contained in:
@@ -106,7 +106,27 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] GetAllPackAssetPaths()
|
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>
|
/// <summary>
|
||||||
@@ -153,13 +173,15 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建AssetBundleBuild类
|
/// 创建AssetBundleBuild类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
public UnityEditor.AssetBundleBuild CreatePipelineBuild(bool replaceAssetPathWithAddress)
|
||||||
{
|
{
|
||||||
// 注意:我们不再支持AssetBundle的变种机制
|
// 注意:我们不再支持AssetBundle的变种机制
|
||||||
AssetBundleBuild build = new AssetBundleBuild();
|
AssetBundleBuild build = new AssetBundleBuild();
|
||||||
build.assetBundleName = BundleName;
|
build.assetBundleName = BundleName;
|
||||||
build.assetBundleVariant = string.Empty;
|
build.assetBundleVariant = string.Empty;
|
||||||
build.assetNames = GetAllPackAssetPaths();
|
build.assetNames = GetAllPackAssetPaths();
|
||||||
|
if (replaceAssetPathWithAddress)
|
||||||
|
build.addressableNames = GetAllPackAssetAddress();
|
||||||
return build;
|
return build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,12 +96,12 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建管线里需要的数据
|
/// 获取构建管线里需要的数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds(bool replaceAssetPathWithAddres)
|
||||||
{
|
{
|
||||||
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
||||||
foreach (var bundleInfo in _bundleInfoDic.Values)
|
foreach (var bundleInfo in _bundleInfoDic.Values)
|
||||||
{
|
{
|
||||||
builds.Add(bundleInfo.CreatePipelineBuild());
|
builds.Add(bundleInfo.CreatePipelineBuild(replaceAssetPathWithAddres));
|
||||||
}
|
}
|
||||||
return builds.ToArray();
|
return builds.ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建补丁清单文件到输出目录
|
/// 创建补丁清单文件到输出目录
|
||||||
/// </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 buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
@@ -36,6 +36,7 @@ namespace YooAsset.Editor
|
|||||||
manifest.SupportExtensionless = buildMapContext.Command.SupportExtensionless;
|
manifest.SupportExtensionless = buildMapContext.Command.SupportExtensionless;
|
||||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
|
manifest.ReplaceAssetPathWithAddress = replaceAssetPathWithAddress;
|
||||||
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
||||||
manifest.BuildBundleType = buildParameters.BuildBundleType;
|
manifest.BuildBundleType = buildParameters.BuildBundleType;
|
||||||
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
||||||
@@ -58,7 +59,13 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 4. 处理内置资源包
|
// 4. 处理内置资源包
|
||||||
if (processBundleDepends)
|
if (processBundleDepends)
|
||||||
|
{
|
||||||
|
// 注意:初始化资源清单建立引用关系
|
||||||
|
manifest.Initialize();
|
||||||
|
|
||||||
ProcessBuiltinBundleDependency(context, manifest);
|
ProcessBuiltinBundleDependency(context, manifest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 创建资源清单文本文件
|
// 创建资源清单文本文件
|
||||||
{
|
{
|
||||||
@@ -302,9 +309,6 @@ namespace YooAsset.Editor
|
|||||||
#region YOOASSET_LEGACY_DEPENDENCY
|
#region YOOASSET_LEGACY_DEPENDENCY
|
||||||
private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
|
private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
|
||||||
{
|
{
|
||||||
// 注意:初始化资源清单建立引用关系
|
|
||||||
ManifestTools.InitManifest(manifest);
|
|
||||||
|
|
||||||
// 注意:如果是可编程构建管线,需要补充内置资源包
|
// 注意:如果是可编程构建管线,需要补充内置资源包
|
||||||
// 注意:该步骤依赖前面的操作!
|
// 注意:该步骤依赖前面的操作!
|
||||||
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ namespace YooAsset.Editor
|
|||||||
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
||||||
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
||||||
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
||||||
|
buildReport.Summary.ReplaceAssetPathWithAddress = builtinBuildParameters.ReplaceAssetPathWithAddress;
|
||||||
}
|
}
|
||||||
else if (buildParameters is ScriptableBuildParameters)
|
else if (buildParameters is ScriptableBuildParameters)
|
||||||
{
|
{
|
||||||
@@ -61,6 +62,7 @@ namespace YooAsset.Editor
|
|||||||
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
||||||
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
||||||
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
||||||
|
buildReport.Summary.ReplaceAssetPathWithAddress = scriptableBuildParameters.ReplaceAssetPathWithAddress;
|
||||||
buildReport.Summary.WriteLinkXML = scriptableBuildParameters.WriteLinkXML;
|
buildReport.Summary.WriteLinkXML = scriptableBuildParameters.WriteLinkXML;
|
||||||
buildReport.Summary.CacheServerHost = scriptableBuildParameters.CacheServerHost;
|
buildReport.Summary.CacheServerHost = scriptableBuildParameters.CacheServerHost;
|
||||||
buildReport.Summary.CacheServerPort = scriptableBuildParameters.CacheServerPort;
|
buildReport.Summary.CacheServerPort = scriptableBuildParameters.CacheServerPort;
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ namespace YooAsset.Editor
|
|||||||
// 开始构建
|
// 开始构建
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
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)
|
if (unityManifest == null)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
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)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IgnoreTypeTreeChanges = true;
|
public bool IgnoreTypeTreeChanges = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用可寻址地址代替资源路径
|
||||||
|
/// 说明:开启此项可以节省运行时清单占用的内存!
|
||||||
|
/// </summary>
|
||||||
|
public bool ReplaceAssetPathWithAddress = false;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取内置构建管线的构建选项
|
/// 获取内置构建管线的构建选项
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
CreateManifestFile(false, false, context);
|
CreateManifestFile(false, false, false, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
CreateManifestFile(false, true, context);
|
CreateManifestFile(false, true, false, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ namespace YooAsset.Editor
|
|||||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
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;
|
IBundleBuildResults buildResults;
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
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)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IgnoreTypeTreeChanges = true;
|
public bool IgnoreTypeTreeChanges = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用可寻址地址代替资源路径
|
||||||
|
/// 说明:开启此项可以节省运行时清单占用的内存!
|
||||||
|
/// </summary>
|
||||||
|
public bool ReplaceAssetPathWithAddress = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自动建立资源对象对图集的依赖关系
|
/// 自动建立资源对象对图集的依赖关系
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ namespace YooAsset.Editor
|
|||||||
public ECompressOption CompressOption;
|
public ECompressOption CompressOption;
|
||||||
public bool DisableWriteTypeTree;
|
public bool DisableWriteTypeTree;
|
||||||
public bool IgnoreTypeTreeChanges;
|
public bool IgnoreTypeTreeChanges;
|
||||||
|
public bool ReplaceAssetPathWithAddress;
|
||||||
public bool WriteLinkXML = true;
|
public bool WriteLinkXML = true;
|
||||||
public string CacheServerHost;
|
public string CacheServerHost;
|
||||||
public int CacheServerPort;
|
public int CacheServerPort;
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ namespace YooAsset.Editor
|
|||||||
BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}");
|
BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}");
|
||||||
BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}");
|
BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}");
|
||||||
BindListViewItem("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}");
|
BindListViewItem("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}");
|
||||||
|
BindListViewItem("ReplaceAssetPathWithAddress", $"{buildReport.Summary.ReplaceAssetPathWithAddress}");
|
||||||
BindListViewItem(string.Empty, string.Empty);
|
BindListViewItem(string.Empty, string.Empty);
|
||||||
|
|
||||||
BindListViewHeader("Build Results");
|
BindListViewHeader("Build Results");
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件格式版本
|
/// 文件格式版本
|
||||||
/// </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.SupportExtensionless);
|
||||||
buffer.WriteBool(manifest.LocationToLower);
|
buffer.WriteBool(manifest.LocationToLower);
|
||||||
buffer.WriteBool(manifest.IncludeAssetGUID);
|
buffer.WriteBool(manifest.IncludeAssetGUID);
|
||||||
|
buffer.WriteBool(manifest.ReplaceAssetPathWithAddress);
|
||||||
buffer.WriteInt32(manifest.OutputNameStyle);
|
buffer.WriteInt32(manifest.OutputNameStyle);
|
||||||
buffer.WriteInt32(manifest.BuildBundleType);
|
buffer.WriteInt32(manifest.BuildBundleType);
|
||||||
buffer.WriteUTF8(manifest.BuildPipeline);
|
buffer.WriteUTF8(manifest.BuildPipeline);
|
||||||
@@ -129,7 +130,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化资源清单
|
// 初始化资源清单
|
||||||
InitManifest(manifest);
|
manifest.Initialize();
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,38 +145,6 @@ namespace YooAsset
|
|||||||
return operation.Manifest;
|
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>
|
||||||
/// 获取资源文件的后缀名
|
/// 获取资源文件的后缀名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -84,7 +84,10 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 读取文件版本
|
// 读取文件版本
|
||||||
string fileVersion = _buffer.ReadUTF8();
|
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;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
@@ -99,6 +102,10 @@ namespace YooAsset
|
|||||||
Manifest.SupportExtensionless = _buffer.ReadBool();
|
Manifest.SupportExtensionless = _buffer.ReadBool();
|
||||||
Manifest.LocationToLower = _buffer.ReadBool();
|
Manifest.LocationToLower = _buffer.ReadBool();
|
||||||
Manifest.IncludeAssetGUID = _buffer.ReadBool();
|
Manifest.IncludeAssetGUID = _buffer.ReadBool();
|
||||||
|
if (fileVer >= ver2025_9_30)
|
||||||
|
Manifest.ReplaceAssetPathWithAddress = _buffer.ReadBool();
|
||||||
|
else
|
||||||
|
Manifest.ReplaceAssetPathWithAddress = false;
|
||||||
Manifest.OutputNameStyle = _buffer.ReadInt32();
|
Manifest.OutputNameStyle = _buffer.ReadInt32();
|
||||||
Manifest.BuildBundleType = _buffer.ReadInt32();
|
Manifest.BuildBundleType = _buffer.ReadInt32();
|
||||||
Manifest.BuildPipeline = _buffer.ReadUTF8();
|
Manifest.BuildPipeline = _buffer.ReadUTF8();
|
||||||
@@ -109,6 +116,8 @@ namespace YooAsset
|
|||||||
// 检测配置
|
// 检测配置
|
||||||
if (Manifest.EnableAddressable && Manifest.LocationToLower)
|
if (Manifest.EnableAddressable && Manifest.LocationToLower)
|
||||||
throw new System.Exception("Addressable not support location to lower !");
|
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;
|
_steps = ESteps.PrepareAssetList;
|
||||||
}
|
}
|
||||||
@@ -122,16 +131,31 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
if (_steps == ESteps.DeserializeAssetList)
|
if (_steps == ESteps.DeserializeAssetList)
|
||||||
{
|
{
|
||||||
|
bool replaceAssetPath = false;
|
||||||
|
if (UnityEngine.Application.isPlaying)
|
||||||
|
{
|
||||||
|
if (Manifest.EnableAddressable && Manifest.ReplaceAssetPathWithAddress)
|
||||||
|
replaceAssetPath = true;
|
||||||
|
}
|
||||||
|
|
||||||
while (_packageAssetCount > 0)
|
while (_packageAssetCount > 0)
|
||||||
{
|
{
|
||||||
var packageAsset = new PackageAsset();
|
var packageAsset = new PackageAsset();
|
||||||
packageAsset.Address = _buffer.ReadUTF8();
|
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.AssetGUID = _buffer.ReadUTF8();
|
||||||
packageAsset.AssetTags = _buffer.ReadUTF8Array();
|
packageAsset.AssetTags = _buffer.ReadUTF8Array();
|
||||||
packageAsset.BundleID = _buffer.ReadInt32();
|
packageAsset.BundleID = _buffer.ReadInt32();
|
||||||
packageAsset.DependBundleIDs = _buffer.ReadInt32Array();
|
packageAsset.DependBundleIDs = _buffer.ReadInt32Array();
|
||||||
FillAssetCollection(Manifest, packageAsset);
|
FillAssetCollection(Manifest, packageAsset, replaceAssetPath);
|
||||||
|
|
||||||
_packageAssetCount--;
|
_packageAssetCount--;
|
||||||
Progress = 1f - _packageAssetCount / _progressTotalValue;
|
Progress = 1f - _packageAssetCount / _progressTotalValue;
|
||||||
@@ -181,7 +205,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.InitManifest)
|
if (_steps == ESteps.InitManifest)
|
||||||
{
|
{
|
||||||
ManifestTools.InitManifest(Manifest);
|
Manifest.Initialize();
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
@@ -228,7 +252,7 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
manifest.AssetPathMapping2 = new Dictionary<string, string>();
|
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);
|
manifest.AssetList.Add(packageAsset);
|
||||||
@@ -274,7 +298,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 添加可寻址地址
|
// 添加可寻址地址
|
||||||
if (manifest.EnableAddressable)
|
if (manifest.EnableAddressable && replaceAssetPath == false)
|
||||||
{
|
{
|
||||||
string location = packageAsset.Address;
|
string location = packageAsset.Address;
|
||||||
if (string.IsNullOrEmpty(location) == false)
|
if (string.IsNullOrEmpty(location) == false)
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IncludeAssetGUID;
|
public bool IncludeAssetGUID;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用可寻址地址代替资源路径
|
||||||
|
/// </summary>
|
||||||
|
public bool ReplaceAssetPathWithAddress;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件名称样式
|
/// 文件名称样式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IncludeAssetGUID;
|
public bool IncludeAssetGUID;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用可寻址地址代替资源路径
|
||||||
|
/// </summary>
|
||||||
|
public bool ReplaceAssetPathWithAddress;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件名称样式
|
/// 文件名称样式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -113,6 +118,38 @@ namespace YooAsset
|
|||||||
public Dictionary<string, PackageBundle> BundleDic3;
|
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>
|
||||||
/// 获取包裹的详细信息
|
/// 获取包裹的详细信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -124,6 +161,7 @@ namespace YooAsset
|
|||||||
details.SupportExtensionless = SupportExtensionless;
|
details.SupportExtensionless = SupportExtensionless;
|
||||||
details.LocationToLower = LocationToLower;
|
details.LocationToLower = LocationToLower;
|
||||||
details.IncludeAssetGUID = IncludeAssetGUID;
|
details.IncludeAssetGUID = IncludeAssetGUID;
|
||||||
|
details.ReplaceAssetPathWithAddress = ReplaceAssetPathWithAddress;
|
||||||
details.OutputNameStyle = OutputNameStyle;
|
details.OutputNameStyle = OutputNameStyle;
|
||||||
details.BuildBundleType = BuildBundleType;
|
details.BuildBundleType = BuildBundleType;
|
||||||
details.BuildPipeline = BuildPipeline;
|
details.BuildPipeline = BuildPipeline;
|
||||||
|
|||||||
@@ -120,6 +120,15 @@ namespace YooAsset
|
|||||||
return (ulong)ReadInt64();
|
return (ulong)ReadInt64();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SkipUTF8()
|
||||||
|
{
|
||||||
|
ushort count = ReadUInt16();
|
||||||
|
if (count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CheckReaderIndex(count);
|
||||||
|
_index += count;
|
||||||
|
}
|
||||||
public string ReadUTF8()
|
public string ReadUTF8()
|
||||||
{
|
{
|
||||||
ushort count = ReadUInt16();
|
ushort count = ReadUInt16();
|
||||||
|
|||||||
Reference in New Issue
Block a user