mirror of https://github.com/tuyoogame/YooAsset
refactor : editor code
parent
82b2a5cc20
commit
e8e7696a4d
|
@ -26,19 +26,9 @@ namespace YooAsset.Editor
|
||||||
public string Address { private set; get; }
|
public string Address { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径
|
/// 资源信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath { private set; get; }
|
public AssetInfo AssetInfo { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源GUID
|
|
||||||
/// </summary>
|
|
||||||
public string AssetGUID { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源类型
|
|
||||||
/// </summary>
|
|
||||||
public System.Type AssetType { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源的分类标签
|
/// 资源的分类标签
|
||||||
|
@ -52,25 +42,19 @@ namespace YooAsset.Editor
|
||||||
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
public List<BuildAssetInfo> 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;
|
CollectorType = collectorType;
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
Address = address;
|
Address = address;
|
||||||
AssetPath = assetPath;
|
AssetInfo = assetInfo;
|
||||||
|
|
||||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
|
||||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
|
||||||
}
|
}
|
||||||
public BuildAssetInfo(string assetPath)
|
public BuildAssetInfo(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
CollectorType = ECollectorType.None;
|
CollectorType = ECollectorType.None;
|
||||||
BundleName = string.Empty;
|
BundleName = string.Empty;
|
||||||
Address = string.Empty;
|
Address = string.Empty;
|
||||||
AssetPath = assetPath;
|
AssetInfo = assetInfo;
|
||||||
|
|
||||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
|
||||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -82,12 +82,12 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加一个打包资源
|
/// 添加一个打包资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PackAsset(BuildAssetInfo assetInfo)
|
public void PackAsset(BuildAssetInfo buildAsset)
|
||||||
{
|
{
|
||||||
if (IsContainsAsset(assetInfo.AssetPath))
|
if (IsContainsAsset(buildAsset.AssetInfo.AssetPath))
|
||||||
throw new System.Exception($"Should never get here ! Asset is existed : {assetInfo.AssetPath}");
|
throw new System.Exception($"Should never get here ! Asset is existed : {buildAsset.AssetInfo.AssetPath}");
|
||||||
|
|
||||||
MainAssets.Add(assetInfo);
|
MainAssets.Add(buildAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -95,9 +95,9 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsContainsAsset(string assetPath)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] GetAllMainAssetPaths()
|
public string[] GetAllMainAssetPaths()
|
||||||
{
|
{
|
||||||
return MainAssets.Select(t => t.AssetPath).ToArray();
|
return MainAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -120,17 +120,17 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
var packAssets = GetAllMainAssetPaths();
|
var packAssets = GetAllMainAssetPaths();
|
||||||
List<string> result = new List<string>(packAssets);
|
List<string> result = new List<string>(packAssets);
|
||||||
foreach (var assetInfo in MainAssets)
|
foreach (var buildAsset in MainAssets)
|
||||||
{
|
{
|
||||||
if (assetInfo.AllDependAssetInfos == null)
|
if (buildAsset.AllDependAssetInfos == null)
|
||||||
continue;
|
continue;
|
||||||
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
foreach (var dependAssetInfo in buildAsset.AllDependAssetInfos)
|
||||||
{
|
{
|
||||||
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||||
if (dependAssetInfo.HasBundleName() == false)
|
if (dependAssetInfo.HasBundleName() == false)
|
||||||
{
|
{
|
||||||
if (result.Contains(dependAssetInfo.AssetPath) == false)
|
if (result.Contains(dependAssetInfo.AssetInfo.AssetPath) == false)
|
||||||
result.Add(dependAssetInfo.AssetPath);
|
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,12 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 冗余的资源列表
|
/// 冗余的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>(1000);
|
public readonly List<ReportRedundancyAsset> RedundancyInfos = new List<ReportRedundancyAsset>(1000);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 未被依赖的资源列表
|
||||||
|
/// </summary>
|
||||||
|
public readonly List<AssetInfo> UndependAssets = new List<AssetInfo>(1000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与构建的资源总数
|
/// 参与构建的资源总数
|
||||||
|
|
|
@ -105,8 +105,8 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
PackageAsset packageAsset = new PackageAsset();
|
PackageAsset packageAsset = new PackageAsset();
|
||||||
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
|
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
|
||||||
packageAsset.AssetPath = assetInfo.AssetPath;
|
packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
|
||||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty;
|
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
|
||||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||||
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
|
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
|
||||||
result.Add(packageAsset);
|
result.Add(packageAsset);
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 冗余资源列表
|
// 冗余资源列表
|
||||||
buildReport.RedundancyInfos = new List<ReportRedundancyInfo>(buildMapContext.RedundancyInfos);
|
buildReport.RedundancyAssets = new List<ReportRedundancyAsset>(buildMapContext.RedundancyInfos);
|
||||||
|
|
||||||
// 序列化文件
|
// 序列化文件
|
||||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
|
@ -140,11 +140,11 @@ namespace YooAsset.Editor
|
||||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||||
{
|
{
|
||||||
BuildAssetInfo findAssetInfo = null;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||||
{
|
{
|
||||||
result.Add(dependAssetInfo.AssetPath);
|
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
|
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
|
||||||
{
|
{
|
||||||
|
BuildMapContext context = new BuildMapContext();
|
||||||
var buildMode = buildParameters.BuildMode;
|
var buildMode = buildParameters.BuildMode;
|
||||||
var packageName = buildParameters.PackageName;
|
var packageName = buildParameters.PackageName;
|
||||||
|
|
||||||
|
@ -21,67 +22,65 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 1. 获取所有收集器收集的资源
|
// 1. 获取所有收集器收集的资源
|
||||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||||
List<CollectAssetInfo> allCollectAssetInfos = collectResult.CollectAssets;
|
List<CollectAssetInfo> allCollectAssets = collectResult.CollectAssets;
|
||||||
|
|
||||||
// 2. 剔除未被引用的依赖项资源
|
// 2. 剔除未被引用的依赖项资源
|
||||||
RemoveZeroReferenceAssets(allCollectAssetInfos);
|
RemoveZeroReferenceAssets(context, allCollectAssets);
|
||||||
|
|
||||||
// 3. 录入所有收集器主动收集的资源
|
// 3. 录入所有收集器主动收集的资源
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetPath) == false)
|
if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetInfo.AssetPath))
|
||||||
{
|
{
|
||||||
|
throw new Exception($"Should never get here !");
|
||||||
|
}
|
||||||
|
|
||||||
if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
|
if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
if (collectAssetInfo.AssetTags.Count > 0)
|
if (collectAssetInfo.AssetTags.Count > 0)
|
||||||
{
|
{
|
||||||
collectAssetInfo.AssetTags.Clear();
|
collectAssetInfo.AssetTags.Clear();
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetPath}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetInfo.AssetPath}");
|
||||||
BuildLogger.Warning(warning);
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetPath);
|
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetInfo);
|
||||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||||
allBuildAssetInfos.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
allBuildAssetInfos.Add(collectAssetInfo.AssetInfo.AssetPath, buildAssetInfo);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception($"Should never get here !");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 录入所有收集资源依赖的其它资源
|
// 4. 录入所有收集资源依赖的其它资源
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
string bundleName = collectAssetInfo.BundleName;
|
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
|
else
|
||||||
{
|
{
|
||||||
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
|
var buildAssetInfo = new BuildAssetInfo(dependAsset);
|
||||||
buildAssetInfo.AddReferenceBundleName(bundleName);
|
buildAssetInfo.AddReferenceBundleName(bundleName);
|
||||||
allBuildAssetInfos.Add(dependAssetPath, buildAssetInfo);
|
allBuildAssetInfos.Add(dependAsset.AssetPath, buildAssetInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 填充所有收集资源的依赖列表
|
// 5. 填充所有收集资源的依赖列表
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
var dependAssetInfos = new List<BuildAssetInfo>(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);
|
dependAssetInfos.Add(value);
|
||||||
else
|
else
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
}
|
}
|
||||||
allBuildAssetInfos[collectAssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
allBuildAssetInfos[collectAssetInfo.AssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 自动收集所有依赖的着色器
|
// 6. 自动收集所有依赖的着色器
|
||||||
|
@ -91,7 +90,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (buildAssetInfo.CollectorType == ECollectorType.None)
|
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);
|
buildAssetInfo.SetShaderBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +99,6 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 记录关键信息
|
// 7. 记录关键信息
|
||||||
BuildMapContext context = new BuildMapContext();
|
|
||||||
context.AssetFileCount = allBuildAssetInfos.Count;
|
context.AssetFileCount = allBuildAssetInfos.Count;
|
||||||
context.Command = collectResult.Command;
|
context.Command = collectResult.Command;
|
||||||
|
|
||||||
|
@ -109,11 +107,9 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (buildAssetInfo.IsRedundancyAsset())
|
if (buildAssetInfo.IsRedundancyAsset())
|
||||||
{
|
{
|
||||||
var redundancyInfo = new ReportRedundancyInfo();
|
var redundancyInfo = new ReportRedundancyAsset();
|
||||||
redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
|
redundancyInfo.AssetInfo = buildAssetInfo.AssetInfo;
|
||||||
redundancyInfo.AssetType = buildAssetInfo.AssetType.Name;
|
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetInfo.AssetPath);
|
||||||
redundancyInfo.AssetGUID = buildAssetInfo.AssetGUID;
|
|
||||||
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
|
|
||||||
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
|
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
|
||||||
context.RedundancyInfos.Add(redundancyInfo);
|
context.RedundancyInfos.Add(redundancyInfo);
|
||||||
}
|
}
|
||||||
|
@ -128,7 +124,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
foreach (var removeValue in removeBuildList)
|
foreach (var removeValue in removeBuildList)
|
||||||
{
|
{
|
||||||
allBuildAssetInfos.Remove(removeValue.AssetPath);
|
allBuildAssetInfos.Remove(removeValue.AssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10. 构建资源列表
|
// 10. 构建资源列表
|
||||||
|
@ -145,35 +141,35 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos)
|
private void RemoveZeroReferenceAssets(BuildMapContext context, List<CollectAssetInfo> allCollectAssets)
|
||||||
{
|
{
|
||||||
// 1. 检测是否任何存在依赖资源
|
// 1. 检测依赖资源收集器是否存在
|
||||||
if (allCollectAssetInfos.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
|
if (allCollectAssets.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 2. 获取所有主资源的依赖资源集合
|
// 2. 获取所有主资源的依赖资源集合
|
||||||
HashSet<string> allDependAsset = new HashSet<string>();
|
HashSet<string> allDependAsset = new HashSet<string>();
|
||||||
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)
|
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
||||||
{
|
{
|
||||||
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
foreach (var dependAsset in collectAsset.DependAssets)
|
||||||
{
|
{
|
||||||
if (allDependAsset.Contains(dependAsset) == false)
|
if (allDependAsset.Contains(dependAsset.AssetPath) == false)
|
||||||
allDependAsset.Add(dependAsset);
|
allDependAsset.Add(dependAsset.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 找出所有零引用的依赖资源集合
|
// 3. 找出所有零引用的依赖资源集合
|
||||||
List<CollectAssetInfo> removeList = new List<CollectAssetInfo>();
|
List<CollectAssetInfo> removeList = new List<CollectAssetInfo>();
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
var collectorType = collectAssetInfo.CollectorType;
|
var collectorType = collectAssetInfo.CollectorType;
|
||||||
if (collectorType == ECollectorType.DependAssetCollector)
|
if (collectorType == ECollectorType.DependAssetCollector)
|
||||||
{
|
{
|
||||||
if (allDependAsset.Contains(collectAssetInfo.AssetPath) == false)
|
if (allDependAsset.Contains(collectAssetInfo.AssetInfo.AssetPath) == false)
|
||||||
removeList.Add(collectAssetInfo);
|
removeList.Add(collectAssetInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,9 +177,10 @@ namespace YooAsset.Editor
|
||||||
// 4. 移除所有零引用的依赖资源
|
// 4. 移除所有零引用的依赖资源
|
||||||
foreach (var removeValue in removeList)
|
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);
|
BuildLogger.Warning(warning);
|
||||||
allCollectAssetInfos.Remove(removeValue);
|
context.UndependAssets.Add(removeValue.AssetInfo);
|
||||||
|
allCollectAssets.Remove(removeValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,9 @@ namespace YooAsset.Editor
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,18 +148,29 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源路径
|
||||||
|
List<string> findAssets =new List<string>();
|
||||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||||
{
|
{
|
||||||
string collectDirectory = CollectPath;
|
string collectDirectory = CollectPath;
|
||||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
string[] findResult = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
||||||
|
findAssets.AddRange(findResult);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string assetPath = CollectPath;
|
||||||
|
findAssets.Add(assetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 收集打包资源信息
|
||||||
foreach (string assetPath in findAssets)
|
foreach (string assetPath in findAssets)
|
||||||
{
|
{
|
||||||
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
var assetInfo = new AssetInfo(assetPath);
|
||||||
|
if (IsValidateAsset(command, assetInfo) && IsCollectAsset(group, assetInfo))
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetPath) == false)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetInfo);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -168,20 +179,6 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string assetPath = CollectPath;
|
|
||||||
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
|
||||||
{
|
|
||||||
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 (command.EnableAddressable)
|
if (command.EnableAddressable)
|
||||||
|
@ -192,7 +189,7 @@ namespace YooAsset.Editor
|
||||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectInfoPair.Value.AssetInfo.AssetPath;
|
||||||
if (string.IsNullOrEmpty(address))
|
if (string.IsNullOrEmpty(address))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -211,61 +208,64 @@ namespace YooAsset.Editor
|
||||||
return result.Values.ToList();
|
return result.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建资源收集类
|
||||||
|
/// </summary>
|
||||||
|
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
string address = GetAddress(command, group, assetPath);
|
string address = GetAddress(command, group, assetInfo);
|
||||||
string bundleName = GetBundleName(command, group, assetPath);
|
string bundleName = GetBundleName(command, group, assetInfo);
|
||||||
List<string> assetTags = GetAssetTags(group);
|
List<string> 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)
|
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||||
collectAssetInfo.DependAssets = new List<string>();
|
collectAssetInfo.DependAssets = new List<AssetInfo>();
|
||||||
else
|
else
|
||||||
collectAssetInfo.DependAssets = GetAllDependencies(command, assetPath);
|
collectAssetInfo.DependAssets = GetAllDependencies(command, assetInfo.AssetPath);
|
||||||
|
|
||||||
return collectAssetInfo;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 忽略文件夹
|
// 忽略文件夹
|
||||||
if (AssetDatabase.IsValidFolder(assetPath))
|
if (AssetDatabase.IsValidFolder(assetInfo.AssetPath))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 忽略编辑器下的类型资源
|
// 忽略编辑器下的类型资源
|
||||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
if (assetInfo.AssetType == typeof(LightingDataAsset))
|
||||||
if (assetType == typeof(LightingDataAsset))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 忽略Unity引擎无法识别的文件
|
// 忽略Unity引擎无法识别的文件
|
||||||
if (command.IgnoreDefaultType)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string fileExtension = System.IO.Path.GetExtension(assetPath);
|
if (DefaultFilterRule.IsIgnoreFile(assetInfo.FileExtension))
|
||||||
if (DefaultFilterRule.IsIgnoreFile(fileExtension))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private bool IsCollectAsset(AssetBundleCollectorGroup group, string assetPath)
|
private bool IsCollectAsset(AssetBundleCollectorGroup group, AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
// 根据规则设置过滤资源文件
|
// 根据规则设置过滤资源文件
|
||||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
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)
|
if (command.EnableAddressable == false)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
@ -274,15 +274,14 @@ namespace YooAsset.Editor
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
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;
|
return adressValue;
|
||||||
}
|
}
|
||||||
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (command.AutoCollectShaders)
|
if (command.AutoCollectShaders)
|
||||||
{
|
{
|
||||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
if (assetInfo.IsShaderAsset())
|
||||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
|
||||||
{
|
{
|
||||||
// 获取着色器打包规则结果
|
// 获取着色器打包规则结果
|
||||||
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
|
@ -292,7 +291,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 获取其它资源打包规则结果
|
// 获取其它资源打包规则结果
|
||||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
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);
|
return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
||||||
}
|
}
|
||||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||||
|
@ -302,18 +301,19 @@ namespace YooAsset.Editor
|
||||||
tags.AddRange(temper);
|
tags.AddRange(temper);
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
private List<string> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
||||||
{
|
{
|
||||||
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
||||||
List<string> result = new List<string>(depends.Length);
|
List<AssetInfo> result = new List<AssetInfo>(depends.Length);
|
||||||
foreach (string assetPath in depends)
|
foreach (string assetPath in depends)
|
||||||
{
|
{
|
||||||
// 注意:排除主资源对象
|
// 注意:排除主资源对象
|
||||||
if (assetPath == mainAssetPath)
|
if (assetPath == mainAssetPath)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (IsValidateAsset(command, assetPath))
|
AssetInfo assetInfo = new AssetInfo(assetPath);
|
||||||
result.Add(assetPath);
|
if (IsValidateAsset(command, assetInfo))
|
||||||
|
result.Add(assetInfo);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,12 +89,12 @@ namespace YooAsset.Editor
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
var temper = collector.GetAllCollectAssets(command, this);
|
var temper = collector.GetAllCollectAssets(command, this);
|
||||||
foreach (var assetInfo in temper)
|
foreach (var collectAsset in temper)
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(collectAsset.AssetInfo.AssetPath) == false)
|
||||||
result.Add(assetInfo.AssetPath, assetInfo);
|
result.Add(collectAsset.AssetInfo.AssetPath, collectAsset);
|
||||||
else
|
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)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
var addressTemper = new Dictionary<string, string>();
|
var addressTemper = new Dictionary<string, string>();
|
||||||
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 address = collectAssetPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectAssetPair.Value.AssetInfo.AssetPath;
|
||||||
if (string.IsNullOrEmpty(address))
|
if (string.IsNullOrEmpty(address))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -89,12 +89,12 @@ namespace YooAsset.Editor
|
||||||
foreach (var group in Groups)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
var temper = group.GetAllCollectAssets(command);
|
var temper = group.GetAllCollectAssets(command);
|
||||||
foreach (var assetInfo in temper)
|
foreach (var collectAsset in temper)
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(collectAsset.AssetInfo.AssetPath) == false)
|
||||||
result.Add(assetInfo.AssetPath, assetInfo);
|
result.Add(collectAsset.AssetInfo.AssetPath, collectAsset);
|
||||||
else
|
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)
|
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectInfoPair.Value.AssetInfo.AssetPath;
|
||||||
if (string.IsNullOrEmpty(address))
|
if (string.IsNullOrEmpty(address))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -991,15 +991,15 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
if (collectAssetInfos != null)
|
if (collectAssetInfos != null)
|
||||||
{
|
{
|
||||||
foreach (var collectAssetInfo in collectAssetInfos)
|
foreach (var collectAsset in collectAssetInfos)
|
||||||
{
|
{
|
||||||
VisualElement elementRow = new VisualElement();
|
VisualElement elementRow = new VisualElement();
|
||||||
elementRow.style.flexDirection = FlexDirection.Row;
|
elementRow.style.flexDirection = FlexDirection.Row;
|
||||||
foldout.Add(elementRow);
|
foldout.Add(elementRow);
|
||||||
|
|
||||||
string showInfo = collectAssetInfo.AssetPath;
|
string showInfo = collectAsset.AssetInfo.AssetPath;
|
||||||
if (_enableAddressableToogle.value)
|
if (_enableAddressableToogle.value)
|
||||||
showInfo = $"[{collectAssetInfo.Address}] {collectAssetInfo.AssetPath}";
|
showInfo = $"[{collectAsset.Address}] {collectAsset.AssetInfo.AssetPath}";
|
||||||
|
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.text = showInfo;
|
label.text = showInfo;
|
||||||
|
|
|
@ -21,9 +21,9 @@ namespace YooAsset.Editor
|
||||||
public string Address { private set; get; }
|
public string Address { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径
|
/// 资源信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath { private set; get; }
|
public AssetInfo AssetInfo { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源分类标签
|
/// 资源分类标签
|
||||||
|
@ -33,15 +33,15 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源列表
|
/// 依赖的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> DependAssets = new List<string>();
|
public List<AssetInfo> DependAssets = new List<AssetInfo>();
|
||||||
|
|
||||||
|
|
||||||
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, List<string> assetTags)
|
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, AssetInfo assetInfo, List<string> assetTags)
|
||||||
{
|
{
|
||||||
CollectorType = collectorType;
|
CollectorType = collectorType;
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
Address = address;
|
Address = address;
|
||||||
AssetPath = assetPath;
|
AssetInfo = assetInfo;
|
||||||
AssetTags = assetTags;
|
AssetTags = assetTags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,12 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 冗余的资源列表
|
/// 冗余的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>();
|
public List<ReportRedundancyAsset> RedundancyAssets = new List<ReportRedundancyAsset>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 未被依赖的资源列表
|
||||||
|
/// </summary>
|
||||||
|
public List<AssetInfo> UndependAssets = new List<AssetInfo>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包信息类
|
/// 获取资源包信息类
|
||||||
|
|
|
@ -5,23 +5,12 @@ using System.Collections.Generic;
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ReportRedundancyInfo
|
public class ReportRedundancyAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径
|
/// 资源信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath;
|
public AssetInfo AssetInfo;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源类型
|
|
||||||
/// </summary>
|
|
||||||
public string AssetType;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源GUID
|
|
||||||
/// 说明:Meta文件记录的GUID
|
|
||||||
/// </summary>
|
|
||||||
public string AssetGUID;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源文件大小
|
/// 资源文件大小
|
|
@ -80,16 +80,16 @@ namespace YooAsset.Editor
|
||||||
_assetListView.Rebuild();
|
_assetListView.Rebuild();
|
||||||
RefreshSortingSymbol();
|
RefreshSortingSymbol();
|
||||||
}
|
}
|
||||||
private List<ReportRedundancyInfo> FilterAndSortViewItems()
|
private List<ReportRedundancyAsset> FilterAndSortViewItems()
|
||||||
{
|
{
|
||||||
List<ReportRedundancyInfo> result = new List<ReportRedundancyInfo>(_buildReport.RedundancyInfos.Count);
|
List<ReportRedundancyAsset> result = new List<ReportRedundancyAsset>(_buildReport.RedundancyAssets.Count);
|
||||||
|
|
||||||
// 过滤列表
|
// 过滤列表
|
||||||
foreach (var redundancyInfo in _buildReport.RedundancyInfos)
|
foreach (var redundancyInfo in _buildReport.RedundancyAssets)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_searchKeyWord) == false)
|
if (string.IsNullOrEmpty(_searchKeyWord) == false)
|
||||||
{
|
{
|
||||||
if (redundancyInfo.AssetPath.Contains(_searchKeyWord) == false)
|
if (redundancyInfo.AssetInfo.AssetPath.Contains(_searchKeyWord) == false)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
result.Add(redundancyInfo);
|
result.Add(redundancyInfo);
|
||||||
|
@ -99,16 +99,16 @@ namespace YooAsset.Editor
|
||||||
if (_sortMode == ESortMode.AssetPath)
|
if (_sortMode == ESortMode.AssetPath)
|
||||||
{
|
{
|
||||||
if (_descendingSort)
|
if (_descendingSort)
|
||||||
return result.OrderByDescending(a => a.AssetPath).ToList();
|
return result.OrderByDescending(a => a.AssetInfo.AssetPath).ToList();
|
||||||
else
|
else
|
||||||
return result.OrderBy(a => a.AssetPath).ToList();
|
return result.OrderBy(a => a.AssetInfo.AssetPath).ToList();
|
||||||
}
|
}
|
||||||
else if (_sortMode == ESortMode.AssetType)
|
else if (_sortMode == ESortMode.AssetType)
|
||||||
{
|
{
|
||||||
if (_descendingSort)
|
if (_descendingSort)
|
||||||
return result.OrderByDescending(a => a.AssetType).ToList();
|
return result.OrderByDescending(a => a.AssetInfo.AssetType).ToList();
|
||||||
else
|
else
|
||||||
return result.OrderBy(a => a.AssetType).ToList();
|
return result.OrderBy(a => a.AssetInfo.AssetType).ToList();
|
||||||
}
|
}
|
||||||
else if (_sortMode == ESortMode.FileSize)
|
else if (_sortMode == ESortMode.FileSize)
|
||||||
{
|
{
|
||||||
|
@ -237,16 +237,16 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
private void BindAssetListViewItem(VisualElement element, int index)
|
private void BindAssetListViewItem(VisualElement element, int index)
|
||||||
{
|
{
|
||||||
var sourceData = _assetListView.itemsSource as List<ReportRedundancyInfo>;
|
var sourceData = _assetListView.itemsSource as List<ReportRedundancyAsset>;
|
||||||
var redundancyInfo = sourceData[index];
|
var redundancyInfo = sourceData[index];
|
||||||
|
|
||||||
// Asset Path
|
// Asset Path
|
||||||
var label1 = element.Q<Label>("Label1");
|
var label1 = element.Q<Label>("Label1");
|
||||||
label1.text = redundancyInfo.AssetPath;
|
label1.text = redundancyInfo.AssetInfo.AssetPath;
|
||||||
|
|
||||||
// Asset Type
|
// Asset Type
|
||||||
var label2 = element.Q<Label>("Label2");
|
var label2 = element.Q<Label>("Label2");
|
||||||
label2.text = redundancyInfo.AssetType;
|
label2.text = redundancyInfo.AssetInfo.AssetType.ToString();
|
||||||
|
|
||||||
// File Size
|
// File Size
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4cb0b75b2f649c64bb1d8203f2fbfeea
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,58 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class AssetInfo
|
||||||
|
{
|
||||||
|
private string _fileExtension = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源路径
|
||||||
|
/// </summary>
|
||||||
|
public string AssetPath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源GUID
|
||||||
|
/// </summary>
|
||||||
|
public string AssetGUID;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源类型
|
||||||
|
/// </summary>
|
||||||
|
public System.Type AssetType;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件格式
|
||||||
|
/// </summary>
|
||||||
|
public string FileExtension
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_fileExtension))
|
||||||
|
_fileExtension = System.IO.Path.GetExtension(AssetPath);
|
||||||
|
return _fileExtension;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssetInfo(string assetPath)
|
||||||
|
{
|
||||||
|
AssetPath = assetPath;
|
||||||
|
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(AssetPath);
|
||||||
|
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(AssetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为着色器资源
|
||||||
|
/// </summary>
|
||||||
|
public bool IsShaderAsset()
|
||||||
|
{
|
||||||
|
if (AssetType == typeof(UnityEngine.Shader) || AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4a2e0565919d49348b8deeb14258a985
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue