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