parent
b443a1c308
commit
650d8689ee
|
@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
private string _mainBundleName;
|
private string _mainBundleName;
|
||||||
private string _shareBundleName;
|
private string _shareBundleName;
|
||||||
private readonly HashSet<string> _dependBundleNames = new HashSet<string>();
|
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集器类型
|
/// 收集器类型
|
||||||
|
@ -126,15 +126,15 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置依赖资源包名称
|
/// 添加关联的资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AddDependBundleName(string bundleName)
|
public void AddReferenceBundleName(string bundleName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
if (_dependBundleNames.Contains(bundleName) == false)
|
if (_referenceBundleNames.Contains(bundleName) == false)
|
||||||
_dependBundleNames.Add(bundleName);
|
_referenceBundleNames.Add(bundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -157,9 +157,9 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_dependBundleNames.Count > 1)
|
if (_referenceBundleNames.Count > 1)
|
||||||
{
|
{
|
||||||
var bundleNameList = _dependBundleNames.ToList();
|
var bundleNameList = _referenceBundleNames.ToList();
|
||||||
bundleNameList.Sort();
|
bundleNameList.Sort();
|
||||||
string combineName = string.Join("|", bundleNameList);
|
string combineName = string.Join("|", bundleNameList);
|
||||||
var combineNameHash = HashUtility.StringSHA1(combineName);
|
var combineNameHash = HashUtility.StringSHA1(combineName);
|
||||||
|
|
|
@ -105,7 +105,7 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildAssetInfo[] GetAllPatchAssetInfos()
|
public BuildAssetInfo[] GetAllPatchAssetInfos()
|
||||||
{
|
{
|
||||||
return BuildinAssets.Where(t => t.CollectorType == ECollectorType.MainCollector).ToArray();
|
return BuildinAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -5,12 +5,12 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public static class BuildMapHelper
|
public static class BuildMapCreater
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行资源构建上下文
|
/// 执行资源构建上下文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static BuildMapContext SetupBuildMap()
|
public static BuildMapContext CreateBuildMap()
|
||||||
{
|
{
|
||||||
BuildMapContext context = new BuildMapContext();
|
BuildMapContext context = new BuildMapContext();
|
||||||
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
||||||
|
@ -21,7 +21,22 @@ namespace YooAsset.Editor
|
||||||
// 2. 获取所有主动收集的资源
|
// 2. 获取所有主动收集的资源
|
||||||
List<CollectAssetInfo> allCollectAssets = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
List<CollectAssetInfo> allCollectAssets = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
||||||
|
|
||||||
// 3. 录入主动收集的资源
|
// 3. 剔除未被引用的依赖资源
|
||||||
|
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
||||||
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
|
{
|
||||||
|
if (collectAssetInfo.CollectorType == ECollectorType.DependAssetCollector)
|
||||||
|
{
|
||||||
|
if (IsRemoveDependAsset(allCollectAssets, collectAssetInfo.AssetPath))
|
||||||
|
removeDependList.Add(collectAssetInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var removeValue in removeDependList)
|
||||||
|
{
|
||||||
|
allCollectAssets.Remove(removeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 录入主动收集的资源
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
|
if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
|
||||||
|
@ -36,7 +51,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 录入相关依赖的资源
|
// 5. 录入相关依赖的资源
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||||
|
@ -44,20 +59,20 @@ namespace YooAsset.Editor
|
||||||
if (buildAssetDic.ContainsKey(dependAssetPath))
|
if (buildAssetDic.ContainsKey(dependAssetPath))
|
||||||
{
|
{
|
||||||
buildAssetDic[dependAssetPath].AddAssetTags(collectAssetInfo.AssetTags);
|
buildAssetDic[dependAssetPath].AddAssetTags(collectAssetInfo.AssetTags);
|
||||||
buildAssetDic[dependAssetPath].AddDependBundleName(collectAssetInfo.BundleName);
|
buildAssetDic[dependAssetPath].AddReferenceBundleName(collectAssetInfo.BundleName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var buildAssetInfo = new BuildAssetInfo(ECollectorType.None, dependAssetPath);
|
var buildAssetInfo = new BuildAssetInfo(ECollectorType.None, dependAssetPath);
|
||||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||||
buildAssetInfo.AddDependBundleName(collectAssetInfo.BundleName);
|
buildAssetInfo.AddReferenceBundleName(collectAssetInfo.BundleName);
|
||||||
buildAssetDic.Add(dependAssetPath, buildAssetInfo);
|
buildAssetDic.Add(dependAssetPath, buildAssetInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.AssetFileCount = buildAssetDic.Count;
|
context.AssetFileCount = buildAssetDic.Count;
|
||||||
|
|
||||||
// 5. 填充主动收集资源的依赖列表
|
// 6. 填充主动收集资源的依赖列表
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||||
|
@ -71,26 +86,26 @@ namespace YooAsset.Editor
|
||||||
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 计算完整的资源包名
|
// 7. 计算完整的资源包名
|
||||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||||
{
|
{
|
||||||
pair.Value.CalculateFullBundleName();
|
pair.Value.CalculateFullBundleName();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 移除未参与构建的资源
|
// 8. 移除未参与构建的资源
|
||||||
List<BuildAssetInfo> removeList = new List<BuildAssetInfo>();
|
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||||
{
|
{
|
||||||
var buildAssetInfo = pair.Value;
|
var buildAssetInfo = pair.Value;
|
||||||
if (buildAssetInfo.HasBundleName() == false)
|
if (buildAssetInfo.HasBundleName() == false)
|
||||||
removeList.Add(buildAssetInfo);
|
removeBuildList.Add(buildAssetInfo);
|
||||||
}
|
}
|
||||||
foreach (var removeValue in removeList)
|
foreach (var removeValue in removeBuildList)
|
||||||
{
|
{
|
||||||
buildAssetDic.Remove(removeValue.AssetPath);
|
buildAssetDic.Remove(removeValue.AssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. 构建资源包
|
// 9. 构建资源包
|
||||||
var allBuildinAssets = buildAssetDic.Values.ToList();
|
var allBuildinAssets = buildAssetDic.Values.ToList();
|
||||||
if (allBuildinAssets.Count == 0)
|
if (allBuildinAssets.Count == 0)
|
||||||
throw new Exception("构建的资源列表不能为空");
|
throw new Exception("构建的资源列表不能为空");
|
||||||
|
@ -100,5 +115,20 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
private static bool IsRemoveDependAsset(List<CollectAssetInfo> allCollectAssets, string dependAssetPath)
|
||||||
|
{
|
||||||
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
|
{
|
||||||
|
var collectorType = collectAssetInfo.CollectorType;
|
||||||
|
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
||||||
|
{
|
||||||
|
if (collectAssetInfo.DependAssets.Contains(dependAssetPath))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UnityEngine.Debug.Log($"发现未被依赖的资源并自动移除 : {dependAssetPath}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
|
@ -24,6 +25,8 @@ namespace YooAsset.Editor
|
||||||
IBuildTask task = pipeline[i];
|
IBuildTask task = pipeline[i];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var taskAttribute = task.GetType().GetCustomAttribute<TaskAttribute>();
|
||||||
|
Debug.Log($"---------------------------------------->{taskAttribute.Desc}");
|
||||||
task.Run(context);
|
task.Run(context);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
public class TaskAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string Desc;
|
||||||
|
public TaskAttribute(string desc)
|
||||||
|
{
|
||||||
|
Desc = desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 35749e57d9a3da84aa60c348bc6bbe9d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -8,6 +8,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
[TaskAttribute("资源构建内容打包")]
|
||||||
public class TaskBuilding : IBuildTask
|
public class TaskBuilding : IBuildTask
|
||||||
{
|
{
|
||||||
public class UnityManifestContext : IContextObject
|
public class UnityManifestContext : IContextObject
|
||||||
|
@ -20,12 +21,12 @@ namespace YooAsset.Editor
|
||||||
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
Debug.Log($"开始构建......");
|
|
||||||
BuildAssetBundleOptions opt = buildParametersContext.GetPipelineBuildOptions();
|
BuildAssetBundleOptions opt = buildParametersContext.GetPipelineBuildOptions();
|
||||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(buildParametersContext.PipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), opt, buildParametersContext.Parameters.BuildTarget);
|
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(buildParametersContext.PipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), opt, buildParametersContext.Parameters.BuildTarget);
|
||||||
if (unityManifest == null)
|
if (unityManifest == null)
|
||||||
throw new Exception("构建过程中发生错误!");
|
throw new Exception("构建过程中发生错误!");
|
||||||
|
|
||||||
|
Debug.Log("Unity引擎打包成功!");
|
||||||
UnityManifestContext unityManifestContext = new UnityManifestContext();
|
UnityManifestContext unityManifestContext = new UnityManifestContext();
|
||||||
unityManifestContext.UnityManifest = unityManifest;
|
unityManifestContext.UnityManifest = unityManifest;
|
||||||
context.SetContextObject(unityManifestContext);
|
context.SetContextObject(unityManifestContext);
|
||||||
|
|
|
@ -6,9 +6,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
[TaskAttribute("拷贝内置文件到流目录")]
|
||||||
/// 拷贝内置文件到StreamingAssets
|
|
||||||
/// </summary>
|
|
||||||
public class TaskCopyBuildinFiles : IBuildTask
|
public class TaskCopyBuildinFiles : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -38,7 +36,6 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}";
|
string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}";
|
||||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{patchBundle.Hash}";
|
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{patchBundle.Hash}";
|
||||||
Debug.Log($"拷贝内置文件到流目录:{patchBundle.BundleName}");
|
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +62,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 刷新目录
|
// 刷新目录
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
|
Debug.Log($"内置文件拷贝完成:{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,9 +5,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
[TaskAttribute("创建补丁清单文件")]
|
||||||
/// 创建补丁清单文件
|
|
||||||
/// </summary>
|
|
||||||
public class TaskCreatePatchManifest : IBuildTask
|
public class TaskCreatePatchManifest : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -3,9 +3,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
[TaskAttribute("制作补丁包")]
|
||||||
/// 制作补丁包
|
|
||||||
/// </summary>
|
|
||||||
public class TaskCreatePatchPackage : IBuildTask
|
public class TaskCreatePatchPackage : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -24,7 +22,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
||||||
string packageDirectory = buildParameters.GetPackageDirectory();
|
string packageDirectory = buildParameters.GetPackageDirectory();
|
||||||
UnityEngine.Debug.Log($"准备开始拷贝补丁文件到补丁包目录:{packageDirectory}");
|
UnityEngine.Debug.Log($"开始拷贝补丁文件到补丁包目录:{packageDirectory}");
|
||||||
|
|
||||||
// 拷贝Report文件
|
// 拷贝Report文件
|
||||||
{
|
{
|
||||||
|
@ -32,7 +30,6 @@ namespace YooAsset.Editor
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{reportFileName}";
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{reportFileName}";
|
||||||
string destPath = $"{packageDirectory}/{reportFileName}";
|
string destPath = $"{packageDirectory}/{reportFileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
UnityEngine.Debug.Log($"拷贝构建报告文件到:{destPath}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝补丁清单文件
|
// 拷贝补丁清单文件
|
||||||
|
@ -40,7 +37,6 @@ namespace YooAsset.Editor
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||||
string destPath = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
string destPath = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
UnityEngine.Debug.Log($"拷贝补丁清单文件到:{destPath}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝补丁清单哈希文件
|
// 拷贝补丁清单哈希文件
|
||||||
|
@ -48,7 +44,6 @@ namespace YooAsset.Editor
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||||
string destPath = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
string destPath = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
UnityEngine.Debug.Log($"拷贝补丁清单哈希文件到:{destPath}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝静态版本文件
|
// 拷贝静态版本文件
|
||||||
|
@ -56,7 +51,6 @@ namespace YooAsset.Editor
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||||
string destPath = $"{packageDirectory}/{YooAssetSettings.VersionFileName}";
|
string destPath = $"{packageDirectory}/{YooAssetSettings.VersionFileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
UnityEngine.Debug.Log($"拷贝静态版本文件到:{destPath}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝UnityManifest序列化文件
|
// 拷贝UnityManifest序列化文件
|
||||||
|
@ -64,7 +58,6 @@ namespace YooAsset.Editor
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
|
||||||
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
|
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
UnityEngine.Debug.Log($"拷贝UnityManifest文件到:{destPath}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝UnityManifest文本文件
|
// 拷贝UnityManifest文本文件
|
||||||
|
@ -83,7 +76,6 @@ namespace YooAsset.Editor
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{patchBundle.BundleName}";
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{patchBundle.BundleName}";
|
||||||
string destPath = $"{packageDirectory}/{patchBundle.Hash}";
|
string destPath = $"{packageDirectory}/{patchBundle.Hash}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
UnityEngine.Debug.Log($"拷贝补丁文件到补丁包:{patchBundle.BundleName}");
|
|
||||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
|
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
|
|
@ -4,9 +4,7 @@ using System.IO;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
[TaskAttribute("创建构建报告文件")]
|
||||||
/// 创建报告文件
|
|
||||||
/// </summary>
|
|
||||||
public class TaskCreateReport : IBuildTask
|
public class TaskCreateReport : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -93,6 +91,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 序列化文件
|
// 序列化文件
|
||||||
BuildReport.Serialize(filePath, buildReport);
|
BuildReport.Serialize(filePath, buildReport);
|
||||||
|
UnityEngine.Debug.Log($"资源构建报告文件创建完成:{filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
[TaskAttribute("资源包加密")]
|
||||||
public class TaskEncryption : IBuildTask
|
public class TaskEncryption : IBuildTask
|
||||||
{
|
{
|
||||||
public class EncryptionContext : IContextObject
|
public class EncryptionContext : IContextObject
|
||||||
|
@ -54,7 +55,6 @@ namespace YooAsset.Editor
|
||||||
if (encryptionServices == null)
|
if (encryptionServices == null)
|
||||||
return encryptList;
|
return encryptList;
|
||||||
|
|
||||||
UnityEngine.Debug.Log($"开始加密资源文件");
|
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
{
|
{
|
||||||
|
@ -84,6 +84,8 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
|
if(encryptList.Count == 0)
|
||||||
|
UnityEngine.Debug.LogWarning($"没有发现需要加密的文件!");
|
||||||
return encryptList;
|
return encryptList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,14 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
[TaskAttribute("获取资源构建内容")]
|
||||||
public class TaskGetBuildMap : IBuildTask
|
public class TaskGetBuildMap : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildMapContext = BuildMapHelper.SetupBuildMap();
|
var buildMapContext = BuildMapCreater.CreateBuildMap();
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
|
UnityEngine.Debug.Log("构建内容准备完毕!");
|
||||||
|
|
||||||
// 检测构建结果
|
// 检测构建结果
|
||||||
CheckBuildMapContent(buildMapContext);
|
CheckBuildMapContent(buildMapContext);
|
||||||
|
|
|
@ -6,6 +6,7 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
[TaskAttribute("资源构建准备工作")]
|
||||||
public class TaskPrepare : IBuildTask
|
public class TaskPrepare : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -8,6 +8,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
[TaskAttribute("验证构建结果")]
|
||||||
public class TaskVerifyBuildResult : IBuildTask
|
public class TaskVerifyBuildResult : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集器类型
|
/// 收集器类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ECollectorType CollectorType = ECollectorType.MainCollector;
|
public ECollectorType CollectorType = ECollectorType.MainAssetCollector;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 寻址规则类名
|
/// 寻址规则类名
|
||||||
|
@ -47,12 +47,19 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(CollectPath) == null)
|
if (AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(CollectPath) == null)
|
||||||
return false;
|
return false;
|
||||||
if (AssetBundleGrouperSettingData.HasPackRuleName(PackRuleName) == false)
|
|
||||||
return false;
|
if (CollectorType == ECollectorType.None)
|
||||||
if (AssetBundleGrouperSettingData.HasFilterRuleName(FilterRuleName) == false)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (AssetBundleGrouperSettingData.HasAddressRuleName(AddressRuleName) == false)
|
if (AssetBundleGrouperSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (AssetBundleGrouperSettingData.HasPackRuleName(PackRuleName) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (AssetBundleGrouperSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +93,8 @@ namespace YooAsset.Editor
|
||||||
bool isRawAsset = PackRuleName == nameof(PackRawFile);
|
bool isRawAsset = PackRuleName == nameof(PackRawFile);
|
||||||
|
|
||||||
// 检测原生资源包的收集器类型
|
// 检测原生资源包的收集器类型
|
||||||
if (isRawAsset && CollectorType != ECollectorType.MainCollector)
|
if (isRawAsset && CollectorType != ECollectorType.MainAssetCollector)
|
||||||
throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainCollector} : {CollectPath}");
|
throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}");
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||||
|
@ -130,7 +137,7 @@ namespace YooAsset.Editor
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
{
|
{
|
||||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainCollector)
|
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
if (adressTemper.Contains(address) == false)
|
if (adressTemper.Contains(address) == false)
|
||||||
|
@ -189,7 +196,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
private string GetAddress(AssetBundleGrouper grouper, string assetPath)
|
private string GetAddress(AssetBundleGrouper grouper, string assetPath)
|
||||||
{
|
{
|
||||||
if (CollectorType != ECollectorType.MainCollector)
|
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
IAddressRule addressRuleInstance = AssetBundleGrouperSettingData.GetAddressRuleInstance(AddressRuleName);
|
IAddressRule addressRuleInstance = AssetBundleGrouperSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace YooAsset.Editor
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
{
|
{
|
||||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainCollector)
|
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
if (adressTemper.Contains(address) == false)
|
if (adressTemper.Contains(address) == false)
|
||||||
|
|
|
@ -22,14 +22,14 @@ namespace YooAsset.Editor
|
||||||
var collectAssetList = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
var collectAssetList = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
||||||
foreach (var collectAsset in collectAssetList)
|
foreach (var collectAsset in collectAssetList)
|
||||||
{
|
{
|
||||||
if(collectAsset.CollectorType != ECollectorType.MainCollector)
|
if(collectAsset.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
continue;
|
{
|
||||||
|
string address = collectAsset.Address;
|
||||||
string address = collectAsset.Address;
|
if (_locationDic.ContainsKey(address))
|
||||||
if (_locationDic.ContainsKey(address))
|
throw new Exception($"The address is existed : {address} in grouper setting.");
|
||||||
UnityEngine.Debug.LogWarning($"Address have existed : {address}");
|
else
|
||||||
else
|
_locationDic.Add(address, collectAsset);
|
||||||
_locationDic.Add(address, collectAsset);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -37,24 +37,25 @@ namespace YooAsset.Editor
|
||||||
var collectAssetList = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
var collectAssetList = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
||||||
foreach (var collectAsset in collectAssetList)
|
foreach (var collectAsset in collectAssetList)
|
||||||
{
|
{
|
||||||
if (collectAsset.CollectorType != ECollectorType.MainCollector)
|
if (collectAsset.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
continue;
|
|
||||||
|
|
||||||
// 添加原始路径
|
|
||||||
string assetPath = collectAsset.AssetPath;
|
|
||||||
if (_locationDic.ContainsKey(assetPath))
|
|
||||||
UnityEngine.Debug.LogWarning($"Asset path have existed : {assetPath}");
|
|
||||||
else
|
|
||||||
_locationDic.Add(assetPath, collectAsset);
|
|
||||||
|
|
||||||
// 添加去掉后缀名的路径
|
|
||||||
if (Path.HasExtension(assetPath))
|
|
||||||
{
|
{
|
||||||
string assetPathWithoutExtension = StringUtility.RemoveExtension(assetPath);
|
// 添加原始路径
|
||||||
if (_locationDic.ContainsKey(assetPathWithoutExtension))
|
// 注意:我们不允许原始路径存在重名
|
||||||
UnityEngine.Debug.LogWarning($"Asset path have existed : {assetPathWithoutExtension}");
|
string assetPath = collectAsset.AssetPath;
|
||||||
|
if (_locationDic.ContainsKey(assetPath))
|
||||||
|
throw new Exception($"Asset path have existed : {assetPath}");
|
||||||
else
|
else
|
||||||
_locationDic.Add(assetPathWithoutExtension, collectAsset);
|
_locationDic.Add(assetPath, collectAsset);
|
||||||
|
|
||||||
|
// 添加去掉后缀名的路径
|
||||||
|
if (Path.HasExtension(assetPath))
|
||||||
|
{
|
||||||
|
string assetPathWithoutExtension = StringUtility.RemoveExtension(assetPath);
|
||||||
|
if (_locationDic.ContainsKey(assetPathWithoutExtension))
|
||||||
|
UnityEngine.Debug.LogWarning($"Asset path have existed : {assetPathWithoutExtension}");
|
||||||
|
else
|
||||||
|
_locationDic.Add(assetPathWithoutExtension, collectAsset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace YooAsset.Editor
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
{
|
{
|
||||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainCollector)
|
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
if (adressTemper.Contains(address) == false)
|
if (adressTemper.Contains(address) == false)
|
||||||
|
|
|
@ -39,7 +39,12 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
_collectorTypeList = new List<string>() { $"{nameof(ECollectorType.MainCollector)}", $"{nameof(ECollectorType.StaticCollector)}"};
|
_collectorTypeList = new List<string>()
|
||||||
|
{
|
||||||
|
$"{nameof(ECollectorType.MainAssetCollector)}",
|
||||||
|
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
||||||
|
$"{nameof(ECollectorType.DependAssetCollector)}"
|
||||||
|
};
|
||||||
_addressRuleList = AssetBundleGrouperSettingData.GetAddressRuleNames();
|
_addressRuleList = AssetBundleGrouperSettingData.GetAddressRuleNames();
|
||||||
_packRuleList = AssetBundleGrouperSettingData.GetPackRuleNames();
|
_packRuleList = AssetBundleGrouperSettingData.GetPackRuleNames();
|
||||||
_filterRuleList = AssetBundleGrouperSettingData.GetFilterRuleNames();
|
_filterRuleList = AssetBundleGrouperSettingData.GetFilterRuleNames();
|
||||||
|
@ -371,7 +376,7 @@ namespace YooAsset.Editor
|
||||||
var foldout = new Foldout();
|
var foldout = new Foldout();
|
||||||
foldout.name = "Foldout1";
|
foldout.name = "Foldout1";
|
||||||
foldout.value = false;
|
foldout.value = false;
|
||||||
foldout.text = "Assets";
|
foldout.text = "Main Assets";
|
||||||
elementFoldout.Add(foldout);
|
elementFoldout.Add(foldout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,7 +479,13 @@ namespace YooAsset.Editor
|
||||||
// 清空旧元素
|
// 清空旧元素
|
||||||
foldout.Clear();
|
foldout.Clear();
|
||||||
|
|
||||||
if (collector.IsValid() && collector.CollectorType == ECollectorType.MainCollector)
|
if (collector.IsValid() == false)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"The collector is invalid : {collector.CollectPath} in grouper : {grouper.GrouperName}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collector.CollectorType == ECollectorType.MainAssetCollector || collector.CollectorType == ECollectorType.StaticAssetCollector)
|
||||||
{
|
{
|
||||||
List<CollectAssetInfo> collectAssetInfos = null;
|
List<CollectAssetInfo> collectAssetInfos = null;
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,20 @@ namespace YooAsset.Editor
|
||||||
public enum ECollectorType
|
public enum ECollectorType
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集参与打包构建的资源对象,并全部写入到资源清单的资源列表里(可以通过代码加载)。
|
/// 收集参与打包的主资源对象,并写入到资源清单的资源列表里(可以通过代码加载)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
MainCollector,
|
MainAssetCollector,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集参与打包构建的资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
/// 收集参与打包的主资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
StaticCollector,
|
StaticAssetCollector,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 收集参与打包的依赖资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
||||||
|
/// 注意:如果依赖资源对象没有被主资源对象引用,则不参与打包构建。
|
||||||
|
/// </summary>
|
||||||
|
DependAssetCollector,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 该收集器类型不能被设置
|
/// 该收集器类型不能被设置
|
||||||
|
|
Loading…
Reference in New Issue