diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
index d33ed14..c78ff6c 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
@@ -26,19 +26,9 @@ namespace YooAsset.Editor
public string Address { private set; get; }
///
- /// 资源路径
+ /// 资源信息
///
- public string AssetPath { private set; get; }
-
- ///
- /// 资源GUID
- ///
- public string AssetGUID { private set; get; }
-
- ///
- /// 资源类型
- ///
- public System.Type AssetType { private set; get; }
+ public AssetInfo AssetInfo { private set; get; }
///
/// 资源的分类标签
@@ -52,25 +42,19 @@ namespace YooAsset.Editor
public List AllDependAssetInfos { private set; get; }
- public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath)
+ public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, AssetInfo assetInfo)
{
CollectorType = collectorType;
BundleName = bundleName;
Address = address;
- AssetPath = assetPath;
-
- AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
- AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
+ AssetInfo = assetInfo;
}
- public BuildAssetInfo(string assetPath)
+ public BuildAssetInfo(AssetInfo assetInfo)
{
CollectorType = ECollectorType.None;
BundleName = string.Empty;
Address = string.Empty;
- AssetPath = assetPath;
-
- AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
- AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
+ AssetInfo = assetInfo;
}
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs
index ac0111b..5b9997d 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs
@@ -82,12 +82,12 @@ namespace YooAsset.Editor
///
/// 添加一个打包资源
///
- public void PackAsset(BuildAssetInfo assetInfo)
+ public void PackAsset(BuildAssetInfo buildAsset)
{
- if (IsContainsAsset(assetInfo.AssetPath))
- throw new System.Exception($"Should never get here ! Asset is existed : {assetInfo.AssetPath}");
+ if (IsContainsAsset(buildAsset.AssetInfo.AssetPath))
+ throw new System.Exception($"Should never get here ! Asset is existed : {buildAsset.AssetInfo.AssetPath}");
- MainAssets.Add(assetInfo);
+ MainAssets.Add(buildAsset);
}
///
@@ -95,9 +95,9 @@ namespace YooAsset.Editor
///
public bool IsContainsAsset(string assetPath)
{
- foreach (var assetInfo in MainAssets)
+ foreach (var buildAsset in MainAssets)
{
- if (assetInfo.AssetPath == assetPath)
+ if (buildAsset.AssetInfo.AssetPath == assetPath)
{
return true;
}
@@ -110,7 +110,7 @@ namespace YooAsset.Editor
///
public string[] GetAllMainAssetPaths()
{
- return MainAssets.Select(t => t.AssetPath).ToArray();
+ return MainAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
}
///
@@ -120,17 +120,17 @@ namespace YooAsset.Editor
{
var packAssets = GetAllMainAssetPaths();
List result = new List(packAssets);
- foreach (var assetInfo in MainAssets)
+ foreach (var buildAsset in MainAssets)
{
- if (assetInfo.AllDependAssetInfos == null)
+ if (buildAsset.AllDependAssetInfos == null)
continue;
- foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
+ foreach (var dependAssetInfo in buildAsset.AllDependAssetInfos)
{
// 注意:依赖资源里只添加零依赖资源和冗余资源
if (dependAssetInfo.HasBundleName() == false)
{
- if (result.Contains(dependAssetInfo.AssetPath) == false)
- result.Add(dependAssetInfo.AssetPath);
+ if (result.Contains(dependAssetInfo.AssetInfo.AssetPath) == false)
+ result.Add(dependAssetInfo.AssetInfo.AssetPath);
}
}
}
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
index a15833e..d6b6ec9 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
@@ -16,9 +16,13 @@ namespace YooAsset.Editor
///
/// 冗余的资源列表
///
- public readonly List RedundancyInfos = new List(1000);
-
+ public readonly List RedundancyInfos = new List(1000);
+ ///
+ /// 未被依赖的资源列表
+ ///
+ public readonly List UndependAssets = new List(1000);
+
///
/// 参与构建的资源总数
/// 说明:包括主动收集的资源以及其依赖的所有资源
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs
index 05cdb2c..23120ef 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs
@@ -105,8 +105,8 @@ namespace YooAsset.Editor
{
PackageAsset packageAsset = new PackageAsset();
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
- packageAsset.AssetPath = assetInfo.AssetPath;
- packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty;
+ packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
+ packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
result.Add(packageAsset);
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs
index 71d3513..16d700c 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs
@@ -108,7 +108,7 @@ namespace YooAsset.Editor
}
// 冗余资源列表
- buildReport.RedundancyInfos = new List(buildMapContext.RedundancyInfos);
+ buildReport.RedundancyAssets = new List(buildMapContext.RedundancyInfos);
// 序列化文件
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
@@ -140,11 +140,11 @@ namespace YooAsset.Editor
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
{
BuildAssetInfo findAssetInfo = null;
- foreach (var assetInfo in bundleInfo.MainAssets)
+ foreach (var buildAsset in bundleInfo.MainAssets)
{
- if (assetInfo.AssetPath == assetPath)
+ if (buildAsset.AssetInfo.AssetPath == assetPath)
{
- findAssetInfo = assetInfo;
+ findAssetInfo = buildAsset;
break;
}
}
@@ -154,7 +154,7 @@ namespace YooAsset.Editor
}
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
{
- result.Add(dependAssetInfo.AssetPath);
+ result.Add(dependAssetInfo.AssetInfo.AssetPath);
}
}
return result;
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs
index 0583e5f..4c4f2f8 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs
@@ -14,6 +14,7 @@ namespace YooAsset.Editor
///
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
{
+ BuildMapContext context = new BuildMapContext();
var buildMode = buildParameters.BuildMode;
var packageName = buildParameters.PackageName;
@@ -21,67 +22,65 @@ namespace YooAsset.Editor
// 1. 获取所有收集器收集的资源
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
- List allCollectAssetInfos = collectResult.CollectAssets;
+ List allCollectAssets = collectResult.CollectAssets;
// 2. 剔除未被引用的依赖项资源
- RemoveZeroReferenceAssets(allCollectAssetInfos);
+ RemoveZeroReferenceAssets(context, allCollectAssets);
// 3. 录入所有收集器主动收集的资源
- foreach (var collectAssetInfo in allCollectAssetInfos)
+ foreach (var collectAssetInfo in allCollectAssets)
{
- if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetPath) == false)
- {
- if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
- {
- if (collectAssetInfo.AssetTags.Count > 0)
- {
- collectAssetInfo.AssetTags.Clear();
- string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetPath}");
- BuildLogger.Warning(warning);
- }
- }
-
- var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetPath);
- buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
- allBuildAssetInfos.Add(collectAssetInfo.AssetPath, buildAssetInfo);
- }
- else
+ if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetInfo.AssetPath))
{
throw new Exception($"Should never get here !");
}
+
+ if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
+ {
+ if (collectAssetInfo.AssetTags.Count > 0)
+ {
+ collectAssetInfo.AssetTags.Clear();
+ string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetInfo.AssetPath}");
+ BuildLogger.Warning(warning);
+ }
+ }
+
+ var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetInfo);
+ buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
+ allBuildAssetInfos.Add(collectAssetInfo.AssetInfo.AssetPath, buildAssetInfo);
}
// 4. 录入所有收集资源依赖的其它资源
- foreach (var collectAssetInfo in allCollectAssetInfos)
+ foreach (var collectAssetInfo in allCollectAssets)
{
string bundleName = collectAssetInfo.BundleName;
- foreach (var dependAssetPath in collectAssetInfo.DependAssets)
+ foreach (var dependAsset in collectAssetInfo.DependAssets)
{
- if (allBuildAssetInfos.ContainsKey(dependAssetPath))
+ if (allBuildAssetInfos.ContainsKey(dependAsset.AssetPath))
{
- allBuildAssetInfos[dependAssetPath].AddReferenceBundleName(bundleName);
+ allBuildAssetInfos[dependAsset.AssetPath].AddReferenceBundleName(bundleName);
}
else
{
- var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
+ var buildAssetInfo = new BuildAssetInfo(dependAsset);
buildAssetInfo.AddReferenceBundleName(bundleName);
- allBuildAssetInfos.Add(dependAssetPath, buildAssetInfo);
+ allBuildAssetInfos.Add(dependAsset.AssetPath, buildAssetInfo);
}
}
}
// 5. 填充所有收集资源的依赖列表
- foreach (var collectAssetInfo in allCollectAssetInfos)
+ foreach (var collectAssetInfo in allCollectAssets)
{
var dependAssetInfos = new List(collectAssetInfo.DependAssets.Count);
- foreach (var dependAssetPath in collectAssetInfo.DependAssets)
+ foreach (var dependAsset in collectAssetInfo.DependAssets)
{
- if (allBuildAssetInfos.TryGetValue(dependAssetPath, out BuildAssetInfo value))
+ if (allBuildAssetInfos.TryGetValue(dependAsset.AssetPath, out BuildAssetInfo value))
dependAssetInfos.Add(value);
else
throw new Exception("Should never get here !");
}
- allBuildAssetInfos[collectAssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
+ allBuildAssetInfos[collectAssetInfo.AssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
}
// 6. 自动收集所有依赖的着色器
@@ -91,7 +90,7 @@ namespace YooAsset.Editor
{
if (buildAssetInfo.CollectorType == ECollectorType.None)
{
- if (buildAssetInfo.AssetType == typeof(UnityEngine.Shader) || buildAssetInfo.AssetType == typeof(UnityEngine.ShaderVariantCollection))
+ if (buildAssetInfo.AssetInfo.IsShaderAsset())
{
buildAssetInfo.SetShaderBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
}
@@ -100,7 +99,6 @@ namespace YooAsset.Editor
}
// 7. 记录关键信息
- BuildMapContext context = new BuildMapContext();
context.AssetFileCount = allBuildAssetInfos.Count;
context.Command = collectResult.Command;
@@ -109,11 +107,9 @@ namespace YooAsset.Editor
{
if (buildAssetInfo.IsRedundancyAsset())
{
- var redundancyInfo = new ReportRedundancyInfo();
- redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
- redundancyInfo.AssetType = buildAssetInfo.AssetType.Name;
- redundancyInfo.AssetGUID = buildAssetInfo.AssetGUID;
- redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
+ var redundancyInfo = new ReportRedundancyAsset();
+ redundancyInfo.AssetInfo = buildAssetInfo.AssetInfo;
+ redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetInfo.AssetPath);
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
context.RedundancyInfos.Add(redundancyInfo);
}
@@ -128,7 +124,7 @@ namespace YooAsset.Editor
}
foreach (var removeValue in removeBuildList)
{
- allBuildAssetInfos.Remove(removeValue.AssetPath);
+ allBuildAssetInfos.Remove(removeValue.AssetInfo.AssetPath);
}
// 10. 构建资源列表
@@ -145,35 +141,35 @@ namespace YooAsset.Editor
return context;
}
- private void RemoveZeroReferenceAssets(List allCollectAssetInfos)
+ private void RemoveZeroReferenceAssets(BuildMapContext context, List allCollectAssets)
{
- // 1. 检测是否任何存在依赖资源
- if (allCollectAssetInfos.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
+ // 1. 检测依赖资源收集器是否存在
+ if (allCollectAssets.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
return;
// 2. 获取所有主资源的依赖资源集合
HashSet allDependAsset = new HashSet();
- foreach (var collectAssetInfo in allCollectAssetInfos)
+ foreach (var collectAsset in allCollectAssets)
{
- var collectorType = collectAssetInfo.CollectorType;
+ var collectorType = collectAsset.CollectorType;
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
{
- foreach (var dependAsset in collectAssetInfo.DependAssets)
+ foreach (var dependAsset in collectAsset.DependAssets)
{
- if (allDependAsset.Contains(dependAsset) == false)
- allDependAsset.Add(dependAsset);
+ if (allDependAsset.Contains(dependAsset.AssetPath) == false)
+ allDependAsset.Add(dependAsset.AssetPath);
}
}
}
// 3. 找出所有零引用的依赖资源集合
List removeList = new List();
- foreach (var collectAssetInfo in allCollectAssetInfos)
+ foreach (var collectAssetInfo in allCollectAssets)
{
var collectorType = collectAssetInfo.CollectorType;
if (collectorType == ECollectorType.DependAssetCollector)
{
- if (allDependAsset.Contains(collectAssetInfo.AssetPath) == false)
+ if (allDependAsset.Contains(collectAssetInfo.AssetInfo.AssetPath) == false)
removeList.Add(collectAssetInfo);
}
}
@@ -181,9 +177,10 @@ namespace YooAsset.Editor
// 4. 移除所有零引用的依赖资源
foreach (var removeValue in removeList)
{
- string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetPath}");
+ string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetInfo.AssetPath}");
BuildLogger.Warning(warning);
- allCollectAssetInfos.Remove(removeValue);
+ context.UndependAssets.Add(removeValue.AssetInfo);
+ allCollectAssets.Remove(removeValue);
}
}
}
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskBuilding_RFBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskBuilding_RFBP.cs
index 8a10f24..cacb1df 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskBuilding_RFBP.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskBuilding_RFBP.cs
@@ -29,9 +29,9 @@ namespace YooAsset.Editor
foreach (var bundleInfo in buildMapContext.Collection)
{
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
- foreach (var assetInfo in bundleInfo.MainAssets)
+ foreach (var buildAsset in bundleInfo.MainAssets)
{
- EditorTools.CopyFile(assetInfo.AssetPath, dest, true);
+ EditorTools.CopyFile(buildAsset.AssetInfo.AssetPath, dest, true);
}
}
}
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
index 069b707..dbf9612 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
@@ -148,38 +148,35 @@ namespace YooAsset.Editor
Dictionary result = new Dictionary(1000);
- // 收集打包资源
+ // 收集打包资源路径
+ List findAssets =new List();
if (AssetDatabase.IsValidFolder(CollectPath))
{
string collectDirectory = CollectPath;
- string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
- foreach (string assetPath in findAssets)
- {
- if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
- {
- if (result.ContainsKey(assetPath) == false)
- {
- var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
- result.Add(assetPath, collectAssetInfo);
- }
- else
- {
- throw new Exception($"The collecting asset file is existed : {assetPath} in collector : {CollectPath}");
- }
- }
- }
+ string[] findResult = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
+ findAssets.AddRange(findResult);
}
else
{
string assetPath = CollectPath;
- if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
+ findAssets.Add(assetPath);
+ }
+
+ // 收集打包资源信息
+ foreach (string assetPath in findAssets)
+ {
+ var assetInfo = new AssetInfo(assetPath);
+ if (IsValidateAsset(command, assetInfo) && IsCollectAsset(group, assetInfo))
{
- var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
- result.Add(assetPath, collectAssetInfo);
- }
- else
- {
- throw new Exception($"The collecting single asset file is invalid : {assetPath} in collector : {CollectPath}");
+ if (result.ContainsKey(assetPath) == false)
+ {
+ var collectAssetInfo = CreateCollectAssetInfo(command, group, assetInfo);
+ result.Add(assetPath, collectAssetInfo);
+ }
+ else
+ {
+ throw new Exception($"The collecting asset file is existed : {assetPath} in collector : {CollectPath}");
+ }
}
}
@@ -192,7 +189,7 @@ namespace YooAsset.Editor
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
{
string address = collectInfoPair.Value.Address;
- string assetPath = collectInfoPair.Value.AssetPath;
+ string assetPath = collectInfoPair.Value.AssetInfo.AssetPath;
if (string.IsNullOrEmpty(address))
continue;
@@ -211,61 +208,64 @@ namespace YooAsset.Editor
return result.Values.ToList();
}
- private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
+
+ ///
+ /// 创建资源收集类
+ ///
+ private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, AssetInfo assetInfo)
{
- string address = GetAddress(command, group, assetPath);
- string bundleName = GetBundleName(command, group, assetPath);
+ string address = GetAddress(command, group, assetInfo);
+ string bundleName = GetBundleName(command, group, assetInfo);
List assetTags = GetAssetTags(group);
- CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags);
+ CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetInfo, assetTags);
// 注意:模拟构建模式下不需要收集依赖资源
if (command.BuildMode == EBuildMode.SimulateBuild)
- collectAssetInfo.DependAssets = new List();
+ collectAssetInfo.DependAssets = new List();
else
- collectAssetInfo.DependAssets = GetAllDependencies(command, assetPath);
+ collectAssetInfo.DependAssets = GetAllDependencies(command, assetInfo.AssetPath);
return collectAssetInfo;
}
- private bool IsValidateAsset(CollectCommand command, string assetPath)
+
+ private bool IsValidateAsset(CollectCommand command, AssetInfo assetInfo)
{
- if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
+ if (assetInfo.AssetPath.StartsWith("Assets/") == false && assetInfo.AssetPath.StartsWith("Packages/") == false)
{
- UnityEngine.Debug.LogError($"Invalid asset path : {assetPath}");
+ UnityEngine.Debug.LogError($"Invalid asset path : {assetInfo.AssetPath}");
return false;
}
// 忽略文件夹
- if (AssetDatabase.IsValidFolder(assetPath))
+ if (AssetDatabase.IsValidFolder(assetInfo.AssetPath))
return false;
// 忽略编辑器下的类型资源
- Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
- if (assetType == typeof(LightingDataAsset))
+ if (assetInfo.AssetType == typeof(LightingDataAsset))
return false;
// 忽略Unity引擎无法识别的文件
if (command.IgnoreDefaultType)
{
- if (assetType == typeof(UnityEditor.DefaultAsset))
+ if (assetInfo.AssetType == typeof(UnityEditor.DefaultAsset))
{
- UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
+ UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetInfo.AssetPath}");
return false;
}
}
- string fileExtension = System.IO.Path.GetExtension(assetPath);
- if (DefaultFilterRule.IsIgnoreFile(fileExtension))
+ if (DefaultFilterRule.IsIgnoreFile(assetInfo.FileExtension))
return false;
return true;
}
- private bool IsCollectAsset(AssetBundleCollectorGroup group, string assetPath)
+ private bool IsCollectAsset(AssetBundleCollectorGroup group, AssetInfo assetInfo)
{
// 根据规则设置过滤资源文件
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
- return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath, CollectPath, group.GroupName, UserData));
+ return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetInfo.AssetPath, CollectPath, group.GroupName, UserData));
}
- private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
+ private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, AssetInfo assetInfo)
{
if (command.EnableAddressable == false)
return string.Empty;
@@ -274,15 +274,14 @@ namespace YooAsset.Editor
return string.Empty;
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
- string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, UserData));
+ string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetInfo.AssetPath, CollectPath, group.GroupName, UserData));
return adressValue;
}
- private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
+ private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, AssetInfo assetInfo)
{
if (command.AutoCollectShaders)
{
- System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
- if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
+ if (assetInfo.IsShaderAsset())
{
// 获取着色器打包规则结果
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
@@ -292,7 +291,7 @@ namespace YooAsset.Editor
// 获取其它资源打包规则结果
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
- PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData));
+ PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetInfo.AssetPath, CollectPath, group.GroupName, UserData));
return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
}
private List GetAssetTags(AssetBundleCollectorGroup group)
@@ -302,18 +301,19 @@ namespace YooAsset.Editor
tags.AddRange(temper);
return tags;
}
- private List GetAllDependencies(CollectCommand command, string mainAssetPath)
+ private List GetAllDependencies(CollectCommand command, string mainAssetPath)
{
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
- List result = new List(depends.Length);
+ List result = new List(depends.Length);
foreach (string assetPath in depends)
{
// 注意:排除主资源对象
if (assetPath == mainAssetPath)
continue;
- if (IsValidateAsset(command, assetPath))
- result.Add(assetPath);
+ AssetInfo assetInfo = new AssetInfo(assetPath);
+ if (IsValidateAsset(command, assetInfo))
+ result.Add(assetInfo);
}
return result;
}
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs
index acf5149..c4c5bb6 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs
@@ -89,12 +89,12 @@ namespace YooAsset.Editor
foreach (var collector in Collectors)
{
var temper = collector.GetAllCollectAssets(command, this);
- foreach (var assetInfo in temper)
+ foreach (var collectAsset in temper)
{
- if (result.ContainsKey(assetInfo.AssetPath) == false)
- result.Add(assetInfo.AssetPath, assetInfo);
+ if (result.ContainsKey(collectAsset.AssetInfo.AssetPath) == false)
+ result.Add(collectAsset.AssetInfo.AssetPath, collectAsset);
else
- throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group : {GroupName}");
+ throw new Exception($"The collecting asset file is existed : {collectAsset.AssetInfo.AssetPath} in group : {GroupName}");
}
}
@@ -102,12 +102,12 @@ namespace YooAsset.Editor
if (command.EnableAddressable)
{
var addressTemper = new Dictionary();
- foreach (var collectInfoPair in result)
+ foreach (var collectAssetPair in result)
{
- if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
+ if (collectAssetPair.Value.CollectorType == ECollectorType.MainAssetCollector)
{
- string address = collectInfoPair.Value.Address;
- string assetPath = collectInfoPair.Value.AssetPath;
+ string address = collectAssetPair.Value.Address;
+ string assetPath = collectAssetPair.Value.AssetInfo.AssetPath;
if (string.IsNullOrEmpty(address))
continue;
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs
index f7f5218..702cfba 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs
@@ -89,12 +89,12 @@ namespace YooAsset.Editor
foreach (var group in Groups)
{
var temper = group.GetAllCollectAssets(command);
- foreach (var assetInfo in temper)
+ foreach (var collectAsset in temper)
{
- if (result.ContainsKey(assetInfo.AssetPath) == false)
- result.Add(assetInfo.AssetPath, assetInfo);
+ if (result.ContainsKey(collectAsset.AssetInfo.AssetPath) == false)
+ result.Add(collectAsset.AssetInfo.AssetPath, collectAsset);
else
- throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath}");
+ throw new Exception($"The collecting asset file is existed : {collectAsset.AssetInfo.AssetPath}");
}
}
@@ -107,7 +107,7 @@ namespace YooAsset.Editor
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
{
string address = collectInfoPair.Value.Address;
- string assetPath = collectInfoPair.Value.AssetPath;
+ string assetPath = collectInfoPair.Value.AssetInfo.AssetPath;
if (string.IsNullOrEmpty(address))
continue;
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
index 56e70f6..85fb93d 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
@@ -991,15 +991,15 @@ namespace YooAsset.Editor
if (collectAssetInfos != null)
{
- foreach (var collectAssetInfo in collectAssetInfos)
+ foreach (var collectAsset in collectAssetInfos)
{
VisualElement elementRow = new VisualElement();
elementRow.style.flexDirection = FlexDirection.Row;
foldout.Add(elementRow);
- string showInfo = collectAssetInfo.AssetPath;
+ string showInfo = collectAsset.AssetInfo.AssetPath;
if (_enableAddressableToogle.value)
- showInfo = $"[{collectAssetInfo.Address}] {collectAssetInfo.AssetPath}";
+ showInfo = $"[{collectAsset.Address}] {collectAsset.AssetInfo.AssetPath}";
var label = new Label();
label.text = showInfo;
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/CollectAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleCollector/CollectAssetInfo.cs
index 20fca0b..f3dbbb6 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/CollectAssetInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/CollectAssetInfo.cs
@@ -21,9 +21,9 @@ namespace YooAsset.Editor
public string Address { private set; get; }
///
- /// 资源路径
+ /// 资源信息
///
- public string AssetPath { private set; get; }
+ public AssetInfo AssetInfo { private set; get; }
///
/// 资源分类标签
@@ -33,15 +33,15 @@ namespace YooAsset.Editor
///
/// 依赖的资源列表
///
- public List DependAssets = new List();
+ public List DependAssets = new List();
- public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, List assetTags)
+ public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, AssetInfo assetInfo, List assetTags)
{
CollectorType = collectorType;
BundleName = bundleName;
Address = address;
- AssetPath = assetPath;
+ AssetInfo = assetInfo;
AssetTags = assetTags;
}
}
diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs b/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs
index f6615fb..7ff89b8 100644
--- a/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs
+++ b/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs
@@ -30,8 +30,12 @@ namespace YooAsset.Editor
///
/// 冗余的资源列表
///
- public List RedundancyInfos = new List();
+ public List RedundancyAssets = new List();
+ ///
+ /// 未被依赖的资源列表
+ ///
+ public List UndependAssets = new List();
///
/// 获取资源包信息类
diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyInfo.cs b/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs
similarity index 53%
rename from Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyInfo.cs
rename to Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs
index 9230725..7cf6b14 100644
--- a/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs
@@ -5,23 +5,12 @@ using System.Collections.Generic;
namespace YooAsset.Editor
{
[Serializable]
- public class ReportRedundancyInfo
+ public class ReportRedundancyAsset
{
///
- /// 资源路径
+ /// 资源信息
///
- public string AssetPath;
-
- ///
- /// 资源类型
- ///
- public string AssetType;
-
- ///
- /// 资源GUID
- /// 说明:Meta文件记录的GUID
- ///
- public string AssetGUID;
+ public AssetInfo AssetInfo;
///
/// 资源文件大小
diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyInfo.cs.meta b/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs.meta
similarity index 100%
rename from Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyInfo.cs.meta
rename to Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs.meta
diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs
index 048a4b0..19d2490 100644
--- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs
+++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs
@@ -80,16 +80,16 @@ namespace YooAsset.Editor
_assetListView.Rebuild();
RefreshSortingSymbol();
}
- private List FilterAndSortViewItems()
+ private List FilterAndSortViewItems()
{
- List result = new List(_buildReport.RedundancyInfos.Count);
+ List result = new List(_buildReport.RedundancyAssets.Count);
// 过滤列表
- foreach (var redundancyInfo in _buildReport.RedundancyInfos)
+ foreach (var redundancyInfo in _buildReport.RedundancyAssets)
{
if (string.IsNullOrEmpty(_searchKeyWord) == false)
{
- if (redundancyInfo.AssetPath.Contains(_searchKeyWord) == false)
+ if (redundancyInfo.AssetInfo.AssetPath.Contains(_searchKeyWord) == false)
continue;
}
result.Add(redundancyInfo);
@@ -99,16 +99,16 @@ namespace YooAsset.Editor
if (_sortMode == ESortMode.AssetPath)
{
if (_descendingSort)
- return result.OrderByDescending(a => a.AssetPath).ToList();
+ return result.OrderByDescending(a => a.AssetInfo.AssetPath).ToList();
else
- return result.OrderBy(a => a.AssetPath).ToList();
+ return result.OrderBy(a => a.AssetInfo.AssetPath).ToList();
}
else if (_sortMode == ESortMode.AssetType)
{
if (_descendingSort)
- return result.OrderByDescending(a => a.AssetType).ToList();
+ return result.OrderByDescending(a => a.AssetInfo.AssetType).ToList();
else
- return result.OrderBy(a => a.AssetType).ToList();
+ return result.OrderBy(a => a.AssetInfo.AssetType).ToList();
}
else if (_sortMode == ESortMode.FileSize)
{
@@ -237,16 +237,16 @@ namespace YooAsset.Editor
}
private void BindAssetListViewItem(VisualElement element, int index)
{
- var sourceData = _assetListView.itemsSource as List;
+ var sourceData = _assetListView.itemsSource as List;
var redundancyInfo = sourceData[index];
// Asset Path
var label1 = element.Q