mirror of https://github.com/tuyoogame/YooAsset
update editor code
1. 移除了BuildParameters.AutoAnalyzeRedundancy字段 2. 移除了DefaultShareAssetPackRule 3. 新增了ZeroRedundancySharedPackRule 4. 新增了FullRedundancySharedPackRulepull/122/head
parent
84f9d1985e
commit
f54c8d6da4
|
@ -275,8 +275,7 @@ namespace YooAsset.Editor
|
||||||
buildParameters.PackageName = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
buildParameters.PackageName = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
||||||
buildParameters.PackageVersion = _buildVersionField.value;
|
buildParameters.PackageVersion = _buildVersionField.value;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.AutoAnalyzeRedundancy = true;
|
buildParameters.SharedPackRule = new ZeroRedundancySharedPackRule();
|
||||||
buildParameters.SharedPackRule = new DefaultSharedPackRule();
|
|
||||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||||
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
||||||
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
|
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
|
||||||
|
|
|
@ -164,7 +164,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算共享资源包的完整包名
|
/// 计算共享资源包的完整包名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CalculateShareBundleName(ISharedPackRule packRule, bool uniqueBundleName, string packageName, string shadersBundleName)
|
public void CalculateShareBundleName(ISharedPackRule sharedPackRule, bool uniqueBundleName, string packageName, string shadersBundleName)
|
||||||
{
|
{
|
||||||
if (CollectorType != ECollectorType.None)
|
if (CollectorType != ECollectorType.None)
|
||||||
return;
|
return;
|
||||||
|
@ -180,7 +180,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (_referenceBundleNames.Count > 1)
|
if (_referenceBundleNames.Count > 1)
|
||||||
{
|
{
|
||||||
PackRuleResult packRuleResult = packRule.GetPackRuleResult(AssetPath);
|
PackRuleResult packRuleResult = sharedPackRule.GetPackRuleResult(AssetPath);
|
||||||
BundleName = packRuleResult.GetShareBundleName(packageName, uniqueBundleName);
|
BundleName = packRuleResult.GetShareBundleName(packageName, uniqueBundleName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -196,12 +196,9 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsRedundancyAsset()
|
public bool IsRedundancyAsset()
|
||||||
{
|
{
|
||||||
if (CollectorType != ECollectorType.None)
|
if (HasBundleName())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (IsRawAsset)
|
|
||||||
throw new Exception("Should never get here !");
|
|
||||||
|
|
||||||
return _referenceBundleNames.Count > 1;
|
return _referenceBundleNames.Count > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与构建的资源列表
|
/// 参与构建的资源列表
|
||||||
/// 注意:不包含零依赖资源
|
/// 注意:不包含零依赖资源和冗余资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<BuildAssetInfo> AllMainAssets = new List<BuildAssetInfo>();
|
public readonly List<BuildAssetInfo> AllMainAssets = new List<BuildAssetInfo>();
|
||||||
|
|
||||||
|
@ -149,7 +149,15 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取该资源包内的所有资源(包括零依赖资源)
|
/// 获取构建的资源路径列表
|
||||||
|
/// </summary>
|
||||||
|
public string[] GetAllMainAssetPaths()
|
||||||
|
{
|
||||||
|
return AllMainAssets.Select(t => t.AssetPath).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取该资源包内的所有资源(包括零依赖资源和冗余资源)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> GetAllBuiltinAssetPaths()
|
public List<string> GetAllBuiltinAssetPaths()
|
||||||
{
|
{
|
||||||
|
@ -161,6 +169,7 @@ namespace YooAsset.Editor
|
||||||
continue;
|
continue;
|
||||||
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
||||||
{
|
{
|
||||||
|
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||||
if (dependAssetInfo.HasBundleName() == false)
|
if (dependAssetInfo.HasBundleName() == false)
|
||||||
{
|
{
|
||||||
if (result.Contains(dependAssetInfo.AssetPath) == false)
|
if (result.Contains(dependAssetInfo.AssetPath) == false)
|
||||||
|
@ -171,22 +180,6 @@ namespace YooAsset.Editor
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取构建的资源路径列表
|
|
||||||
/// </summary>
|
|
||||||
public string[] GetAllMainAssetPaths()
|
|
||||||
{
|
|
||||||
return AllMainAssets.Select(t => t.AssetPath).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取所有写入补丁清单的资源
|
|
||||||
/// </summary>
|
|
||||||
public BuildAssetInfo[] GetAllMainAssetInfos()
|
|
||||||
{
|
|
||||||
return AllMainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建AssetBundleBuild类
|
/// 创建AssetBundleBuild类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -200,6 +193,14 @@ namespace YooAsset.Editor
|
||||||
return build;
|
return build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有写入补丁清单的资源
|
||||||
|
/// </summary>
|
||||||
|
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
||||||
|
{
|
||||||
|
return AllMainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建PackageBundle类
|
/// 创建PackageBundle类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -77,11 +77,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool VerifyBuildingResult = false;
|
public bool VerifyBuildingResult = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自动分析冗余资源
|
|
||||||
/// </summary>
|
|
||||||
public bool AutoAnalyzeRedundancy = true;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 共享资源的打包规则
|
/// 共享资源的打包规则
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -73,11 +73,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UniqueBundleName;
|
public bool UniqueBundleName;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自动分析冗余
|
|
||||||
/// </summary>
|
|
||||||
public bool AutoAnalyzeRedundancy;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 共享资源的打包规则类名
|
/// 共享资源的打包规则类名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace YooAsset.Editor
|
||||||
List<PackageAsset> result = new List<PackageAsset>(1000);
|
List<PackageAsset> result = new List<PackageAsset>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
var assetInfos = bundleInfo.GetAllMainAssetInfos();
|
var assetInfos = bundleInfo.GetAllManifestAssetInfos();
|
||||||
foreach (var assetInfo in assetInfos)
|
foreach (var assetInfo in assetInfos)
|
||||||
{
|
{
|
||||||
PackageAsset packageAsset = new PackageAsset();
|
PackageAsset packageAsset = new PackageAsset();
|
||||||
|
|
|
@ -49,7 +49,6 @@ namespace YooAsset.Editor
|
||||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||||
buildReport.Summary.AutoAnalyzeRedundancy = buildParameters.AutoAnalyzeRedundancy;
|
|
||||||
buildReport.Summary.SharedPackRuleClassName = buildParameters.SharedPackRule == null ?
|
buildReport.Summary.SharedPackRuleClassName = buildParameters.SharedPackRule == null ?
|
||||||
"null" : buildParameters.SharedPackRule.GetType().FullName;
|
"null" : buildParameters.SharedPackRule.GetType().FullName;
|
||||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
|
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
|
||||||
|
@ -161,7 +160,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取该资源包内的所有资源(包括零依赖资源)
|
/// 获取该资源包内的所有资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,6 @@ namespace YooAsset.Editor
|
||||||
var buildMode = buildParameters.BuildMode;
|
var buildMode = buildParameters.BuildMode;
|
||||||
var packageName = buildParameters.PackageName;
|
var packageName = buildParameters.PackageName;
|
||||||
var sharedPackRule = buildParameters.SharedPackRule;
|
var sharedPackRule = buildParameters.SharedPackRule;
|
||||||
var autoAnalyzeRedundancy = buildParameters.AutoAnalyzeRedundancy;
|
|
||||||
|
|
||||||
Dictionary<string, BuildAssetInfo> allBuildAssetInfoDic = new Dictionary<string, BuildAssetInfo>(1000);
|
Dictionary<string, BuildAssetInfo> allBuildAssetInfoDic = new Dictionary<string, BuildAssetInfo>(1000);
|
||||||
|
|
||||||
|
@ -100,34 +99,29 @@ namespace YooAsset.Editor
|
||||||
context.AssetFileCount = allBuildAssetInfoDic.Count;
|
context.AssetFileCount = allBuildAssetInfoDic.Count;
|
||||||
context.Command = collectResult.Command;
|
context.Command = collectResult.Command;
|
||||||
|
|
||||||
// 8. 计算共享的资源包名
|
// 8. 计算共享资源的包名
|
||||||
if (autoAnalyzeRedundancy)
|
var command = collectResult.Command;
|
||||||
|
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
|
||||||
{
|
{
|
||||||
var command = collectResult.Command;
|
buildAssetInfo.CalculateShareBundleName(sharedPackRule, command.UniqueBundleName, command.PackageName, command.ShadersBundleName);
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
|
|
||||||
{
|
|
||||||
buildAssetInfo.CalculateShareBundleName(sharedPackRule, command.UniqueBundleName, command.PackageName, command.ShadersBundleName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// 9. 记录冗余资源
|
||||||
|
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
|
||||||
{
|
{
|
||||||
// 记录冗余资源
|
if (buildAssetInfo.IsRedundancyAsset())
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
|
|
||||||
{
|
{
|
||||||
if (buildAssetInfo.IsRedundancyAsset())
|
var redundancyInfo = new ReportRedundancyInfo();
|
||||||
{
|
redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
|
||||||
var redundancyInfo = new ReportRedundancyInfo();
|
redundancyInfo.AssetType = AssetDatabase.GetMainAssetTypeAtPath(buildAssetInfo.AssetPath).Name;
|
||||||
redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
|
redundancyInfo.AssetGUID = AssetDatabase.AssetPathToGUID(buildAssetInfo.AssetPath);
|
||||||
redundancyInfo.AssetType = AssetDatabase.GetMainAssetTypeAtPath(buildAssetInfo.AssetPath).Name;
|
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
|
||||||
redundancyInfo.AssetGUID = AssetDatabase.AssetPathToGUID(buildAssetInfo.AssetPath);
|
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
|
||||||
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
|
context.RedundancyInfos.Add(redundancyInfo);
|
||||||
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
|
|
||||||
context.RedundancyInfos.Add(redundancyInfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. 移除不参与构建的资源
|
// 10. 移除不参与构建的资源
|
||||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
|
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
|
||||||
{
|
{
|
||||||
|
@ -139,7 +133,7 @@ namespace YooAsset.Editor
|
||||||
allBuildAssetInfoDic.Remove(removeValue.AssetPath);
|
allBuildAssetInfoDic.Remove(removeValue.AssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10. 构建资源包
|
// 11. 构建资源列表
|
||||||
var allPackAssets = allBuildAssetInfoDic.Values.ToList();
|
var allPackAssets = allBuildAssetInfoDic.Values.ToList();
|
||||||
if (allPackAssets.Count == 0)
|
if (allPackAssets.Count == 0)
|
||||||
throw new Exception("构建的资源列表不能为空");
|
throw new Exception("构建的资源列表不能为空");
|
||||||
|
@ -147,6 +141,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
context.PackAsset(assetInfo);
|
context.PackAsset(assetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos)
|
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos)
|
||||||
|
|
|
@ -54,6 +54,10 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetShareBundleName(string packageName, bool uniqueBundleName)
|
public string GetShareBundleName(string packageName, bool uniqueBundleName)
|
||||||
{
|
{
|
||||||
|
// 注意:冗余的共享资源包名返回空
|
||||||
|
if (string.IsNullOrEmpty(_bundleName) && string.IsNullOrEmpty(_bundleExtension))
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
string fullName;
|
string fullName;
|
||||||
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
||||||
if (uniqueBundleName)
|
if (uniqueBundleName)
|
||||||
|
|
|
@ -5,9 +5,9 @@ using UnityEditor;
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 零冗余共享资源打包规则
|
/// 零冗余的共享资源打包规则
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DefaultSharedPackRule : ISharedPackRule
|
public class ZeroRedundancySharedPackRule : ISharedPackRule
|
||||||
{
|
{
|
||||||
public PackRuleResult GetPackRuleResult(string assetPath)
|
public PackRuleResult GetPackRuleResult(string assetPath)
|
||||||
{
|
{
|
||||||
|
@ -16,4 +16,16 @@ namespace YooAsset.Editor
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 全部冗余的共享资源打包规则
|
||||||
|
/// </summary>
|
||||||
|
public class FullRedundancySharedPackRule : ISharedPackRule
|
||||||
|
{
|
||||||
|
public PackRuleResult GetPackRuleResult(string assetPath)
|
||||||
|
{
|
||||||
|
PackRuleResult result = new PackRuleResult(string.Empty, string.Empty);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -71,7 +71,6 @@ namespace YooAsset.Editor
|
||||||
_items.Add(new ItemWrapper("资源定位地址大小写不敏感", $"{buildReport.Summary.LocationToLower}"));
|
_items.Add(new ItemWrapper("资源定位地址大小写不敏感", $"{buildReport.Summary.LocationToLower}"));
|
||||||
_items.Add(new ItemWrapper("包含资源GUID数据", $"{buildReport.Summary.IncludeAssetGUID}"));
|
_items.Add(new ItemWrapper("包含资源GUID数据", $"{buildReport.Summary.IncludeAssetGUID}"));
|
||||||
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}"));
|
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}"));
|
||||||
_items.Add(new ItemWrapper("自动分析冗余资源", $"{buildReport.Summary.AutoAnalyzeRedundancy}"));
|
|
||||||
_items.Add(new ItemWrapper("共享资源打包规则", buildReport.Summary.SharedPackRuleClassName));
|
_items.Add(new ItemWrapper("共享资源打包规则", buildReport.Summary.SharedPackRuleClassName));
|
||||||
_items.Add(new ItemWrapper("资源加密服务类", buildReport.Summary.EncryptionServicesClassName));
|
_items.Add(new ItemWrapper("资源加密服务类", buildReport.Summary.EncryptionServicesClassName));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue