mirror of https://github.com/tuyoogame/YooAsset
parent
2a5a2626a4
commit
ef8229981e
|
@ -37,7 +37,7 @@ namespace YooAsset.Editor
|
||||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
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.IgnoreDefaultType = buildMapContext.Command.IgnoreDefaultType;
|
buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName;
|
||||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
|
|
|
@ -166,7 +166,7 @@ namespace YooAsset.Editor
|
||||||
foreach (string assetPath in findAssets)
|
foreach (string assetPath in findAssets)
|
||||||
{
|
{
|
||||||
var assetInfo = new AssetInfo(assetPath);
|
var assetInfo = new AssetInfo(assetPath);
|
||||||
if (IsValidateAsset(command, assetInfo) && IsCollectAsset(group, assetInfo))
|
if (command.IgnoreRule.IsIgnore(assetInfo) == false && IsCollectAsset(group, assetInfo))
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetPath) == false)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
|
@ -228,37 +228,6 @@ namespace YooAsset.Editor
|
||||||
return collectAssetInfo;
|
return collectAssetInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsValidateAsset(CollectCommand command, AssetInfo assetInfo)
|
|
||||||
{
|
|
||||||
if (assetInfo.AssetPath.StartsWith("Assets/") == false && assetInfo.AssetPath.StartsWith("Packages/") == false)
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.LogError($"Invalid asset path : {assetInfo.AssetPath}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 忽略文件夹
|
|
||||||
if (AssetDatabase.IsValidFolder(assetInfo.AssetPath))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// 忽略编辑器下的类型资源
|
|
||||||
if (assetInfo.AssetType == typeof(LightingDataAsset))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// 忽略Unity引擎无法识别的文件
|
|
||||||
if (command.IgnoreDefaultType)
|
|
||||||
{
|
|
||||||
if (assetInfo.AssetType == typeof(UnityEditor.DefaultAsset))
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetInfo.AssetPath}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DefaultFilterRule.IsIgnoreFile(assetInfo.FileExtension))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private bool IsCollectAsset(AssetBundleCollectorGroup group, AssetInfo assetInfo)
|
private bool IsCollectAsset(AssetBundleCollectorGroup group, AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
// 根据规则设置过滤资源文件
|
// 根据规则设置过滤资源文件
|
||||||
|
@ -312,7 +281,7 @@ namespace YooAsset.Editor
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
AssetInfo assetInfo = new AssetInfo(assetPath);
|
AssetInfo assetInfo = new AssetInfo(assetPath);
|
||||||
if (IsValidateAsset(command, assetInfo))
|
if (command.IgnoreRule.IsIgnore(assetInfo) == false)
|
||||||
result.Add(assetInfo);
|
result.Add(assetInfo);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace YooAsset.Editor
|
||||||
public const string XmlEnableAddressable = "AutoAddressable";
|
public const string XmlEnableAddressable = "AutoAddressable";
|
||||||
public const string XmlLocationToLower = "LocationToLower";
|
public const string XmlLocationToLower = "LocationToLower";
|
||||||
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
||||||
public const string XmlIgnoreDefaultType = "IgnoreDefaultType";
|
public const string XmlIgnoreRuleName = "IgnoreRuleName";
|
||||||
|
|
||||||
public const string XmlGroup = "Group";
|
public const string XmlGroup = "Group";
|
||||||
public const string XmlGroupActiveRule = "GroupActiveRule";
|
public const string XmlGroupActiveRule = "GroupActiveRule";
|
||||||
|
@ -101,7 +101,7 @@ namespace YooAsset.Editor
|
||||||
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||||
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
||||||
package.IncludeAssetGUID = packageElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
package.IncludeAssetGUID = packageElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
||||||
package.IgnoreDefaultType = packageElement.GetAttribute(XmlIgnoreDefaultType) == "True" ? true : false;
|
package.IgnoreRuleName = packageElement.GetAttribute(XmlIgnoreRuleName);
|
||||||
packages.Add(package);
|
packages.Add(package);
|
||||||
|
|
||||||
// 读取分组配置
|
// 读取分组配置
|
||||||
|
@ -213,7 +213,7 @@ namespace YooAsset.Editor
|
||||||
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
||||||
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
||||||
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
||||||
packageElement.SetAttribute(XmlIgnoreDefaultType, package.IgnoreDefaultType.ToString());
|
packageElement.SetAttribute(XmlIgnoreRuleName, package.IgnoreRuleName);
|
||||||
root.AppendChild(packageElement);
|
root.AppendChild(packageElement);
|
||||||
|
|
||||||
// 设置分组配置
|
// 设置分组配置
|
||||||
|
|
|
@ -35,16 +35,16 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IncludeAssetGUID = false;
|
public bool IncludeAssetGUID = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 忽略Unity引擎无法识别的文件
|
|
||||||
/// </summary>
|
|
||||||
public bool IgnoreDefaultType = true;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自动收集所有着色器(所有着色器存储在一个资源包内)
|
/// 自动收集所有着色器(所有着色器存储在一个资源包内)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AutoCollectShaders = true;
|
public bool AutoCollectShaders = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源忽略规则名
|
||||||
|
/// </summary>
|
||||||
|
public string IgnoreRuleName = nameof(NormalIgnoreRule);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组列表
|
/// 分组列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -24,7 +24,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UniqueBundleName = false;
|
public bool UniqueBundleName = false;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹列表
|
/// 包裹列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -100,13 +99,13 @@ namespace YooAsset.Editor
|
||||||
package.CheckConfigError();
|
package.CheckConfigError();
|
||||||
|
|
||||||
// 创建资源收集命令
|
// 创建资源收集命令
|
||||||
|
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(package.IgnoreRuleName);
|
||||||
CollectCommand command = new CollectCommand(buildMode, packageName,
|
CollectCommand command = new CollectCommand(buildMode, packageName,
|
||||||
package.EnableAddressable,
|
package.EnableAddressable,
|
||||||
package.LocationToLower,
|
package.LocationToLower,
|
||||||
package.IncludeAssetGUID,
|
package.IncludeAssetGUID,
|
||||||
package.IgnoreDefaultType,
|
|
||||||
package.AutoCollectShaders,
|
package.AutoCollectShaders,
|
||||||
UniqueBundleName);
|
UniqueBundleName, ignoreRule);
|
||||||
|
|
||||||
// 获取收集的资源集合
|
// 获取收集的资源集合
|
||||||
CollectResult collectResult = new CollectResult(command);
|
CollectResult collectResult = new CollectResult(command);
|
||||||
|
|
|
@ -21,6 +21,9 @@ namespace YooAsset.Editor
|
||||||
private static readonly Dictionary<string, System.Type> _cacheFilterRuleTypes = new Dictionary<string, System.Type>();
|
private static readonly Dictionary<string, System.Type> _cacheFilterRuleTypes = new Dictionary<string, System.Type>();
|
||||||
private static readonly Dictionary<string, IFilterRule> _cacheFilterRuleInstance = new Dictionary<string, IFilterRule>();
|
private static readonly Dictionary<string, IFilterRule> _cacheFilterRuleInstance = new Dictionary<string, IFilterRule>();
|
||||||
|
|
||||||
|
private static readonly Dictionary<string, System.Type> _cacheIgnoreRuleTypes = new Dictionary<string, System.Type>();
|
||||||
|
private static readonly Dictionary<string, IIgnoreRule> _cacheIgnoreRuleInstance = new Dictionary<string, IIgnoreRule>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 配置数据是否被修改
|
/// 配置数据是否被修改
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -129,6 +132,29 @@ namespace YooAsset.Editor
|
||||||
_cacheActiveRuleTypes.Add(type.Name, type);
|
_cacheActiveRuleTypes.Add(type.Name, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IIgnoreRule
|
||||||
|
{
|
||||||
|
// 清空缓存集合
|
||||||
|
_cacheIgnoreRuleTypes.Clear();
|
||||||
|
_cacheIgnoreRuleInstance.Clear();
|
||||||
|
|
||||||
|
// 获取所有类型
|
||||||
|
List<Type> types = new List<Type>(100)
|
||||||
|
{
|
||||||
|
typeof(NormalIgnoreRule),
|
||||||
|
typeof(RawFileIgnoreRule),
|
||||||
|
};
|
||||||
|
|
||||||
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IIgnoreRule));
|
||||||
|
types.AddRange(customTypes);
|
||||||
|
for (int i = 0; i < types.Count; i++)
|
||||||
|
{
|
||||||
|
Type type = types[i];
|
||||||
|
if (_cacheIgnoreRuleTypes.ContainsKey(type.Name) == false)
|
||||||
|
_cacheIgnoreRuleTypes.Add(type.Name, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AssetBundleCollectorSetting _setting = null;
|
private static AssetBundleCollectorSetting _setting = null;
|
||||||
|
@ -225,6 +251,18 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
public static List<RuleDisplayName> GetIgnoreRuleNames()
|
||||||
|
{
|
||||||
|
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||||
|
foreach (var pair in _cacheIgnoreRuleTypes)
|
||||||
|
{
|
||||||
|
RuleDisplayName ruleName = new RuleDisplayName();
|
||||||
|
ruleName.ClassName = pair.Key;
|
||||||
|
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||||
|
names.Add(ruleName);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
private static string GetRuleDisplayName(string name, Type type)
|
private static string GetRuleDisplayName(string name, Type type)
|
||||||
{
|
{
|
||||||
var attribute = DisplayNameAttributeHelper.GetAttribute<DisplayNameAttribute>(type);
|
var attribute = DisplayNameAttributeHelper.GetAttribute<DisplayNameAttribute>(type);
|
||||||
|
@ -250,6 +288,10 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
|
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
|
||||||
}
|
}
|
||||||
|
public static bool HasIgnoreRuleName(string ruleName)
|
||||||
|
{
|
||||||
|
return _cacheIgnoreRuleTypes.Keys.Contains(ruleName);
|
||||||
|
}
|
||||||
|
|
||||||
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
||||||
{
|
{
|
||||||
|
@ -319,6 +361,23 @@ namespace YooAsset.Editor
|
||||||
throw new Exception($"{nameof(IFilterRule)} is invalid:{ruleName}");
|
throw new Exception($"{nameof(IFilterRule)} is invalid:{ruleName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static IIgnoreRule GetIgnoreRuleInstance(string ruleName)
|
||||||
|
{
|
||||||
|
if (_cacheIgnoreRuleInstance.TryGetValue(ruleName, out IIgnoreRule instance))
|
||||||
|
return instance;
|
||||||
|
|
||||||
|
// 如果不存在创建类的实例
|
||||||
|
if (_cacheIgnoreRuleTypes.TryGetValue(ruleName, out Type type))
|
||||||
|
{
|
||||||
|
instance = (IIgnoreRule)Activator.CreateInstance(type);
|
||||||
|
_cacheIgnoreRuleInstance.Add(ruleName, instance);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{nameof(IIgnoreRule)} is invalid:{ruleName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 公共参数编辑相关
|
// 公共参数编辑相关
|
||||||
public static void ModifyShowPackageView(bool showPackageView)
|
public static void ModifyShowPackageView(bool showPackageView)
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace YooAsset.Editor
|
||||||
private List<RuleDisplayName> _addressRuleList;
|
private List<RuleDisplayName> _addressRuleList;
|
||||||
private List<RuleDisplayName> _packRuleList;
|
private List<RuleDisplayName> _packRuleList;
|
||||||
private List<RuleDisplayName> _filterRuleList;
|
private List<RuleDisplayName> _filterRuleList;
|
||||||
|
private List<RuleDisplayName> _ignoreRuleList;
|
||||||
|
|
||||||
private VisualElement _helpBoxContainer;
|
private VisualElement _helpBoxContainer;
|
||||||
|
|
||||||
|
@ -39,9 +40,9 @@ namespace YooAsset.Editor
|
||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
private Toggle _locationToLowerToogle;
|
private Toggle _locationToLowerToogle;
|
||||||
private Toggle _includeAssetGUIDToogle;
|
private Toggle _includeAssetGUIDToogle;
|
||||||
private Toggle _ignoreDefaultTypeToogle;
|
|
||||||
private Toggle _autoCollectShadersToogle;
|
private Toggle _autoCollectShadersToogle;
|
||||||
|
private PopupField<RuleDisplayName> _ignoreRulePopupField;
|
||||||
|
|
||||||
private VisualElement _packageContainer;
|
private VisualElement _packageContainer;
|
||||||
private ListView _packageListView;
|
private ListView _packageListView;
|
||||||
private TextField _packageNameTxt;
|
private TextField _packageNameTxt;
|
||||||
|
@ -77,6 +78,7 @@ namespace YooAsset.Editor
|
||||||
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
||||||
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
||||||
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
||||||
|
_ignoreRuleList = AssetBundleCollectorSettingData.GetIgnoreRuleNames();
|
||||||
|
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
|
@ -151,17 +153,6 @@ namespace YooAsset.Editor
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_ignoreDefaultTypeToogle = root.Q<Toggle>("IgnoreDefaultType");
|
|
||||||
_ignoreDefaultTypeToogle.RegisterValueChangedCallback(evt =>
|
|
||||||
{
|
|
||||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
|
||||||
if (selectPackage != null)
|
|
||||||
{
|
|
||||||
selectPackage.IgnoreDefaultType = evt.newValue;
|
|
||||||
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
|
||||||
RefreshWindow();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
_autoCollectShadersToogle = root.Q<Toggle>("AutoCollectShaders");
|
_autoCollectShadersToogle = root.Q<Toggle>("AutoCollectShaders");
|
||||||
_autoCollectShadersToogle.RegisterValueChangedCallback(evt =>
|
_autoCollectShadersToogle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
@ -173,6 +164,25 @@ namespace YooAsset.Editor
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
{
|
||||||
|
_ignoreRulePopupField = new PopupField<RuleDisplayName>(_ignoreRuleList, 0);
|
||||||
|
_ignoreRulePopupField.label = "File Ignore Rule";
|
||||||
|
_ignoreRulePopupField.name = "IgnoreRulePopupField";
|
||||||
|
_ignoreRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
_ignoreRulePopupField.style.width = 300;
|
||||||
|
_ignoreRulePopupField.formatListItemCallback = FormatListItemCallback;
|
||||||
|
_ignoreRulePopupField.formatSelectedValueCallback = FormatSelectedValueCallback;
|
||||||
|
_ignoreRulePopupField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||||
|
if(selectPackage != null)
|
||||||
|
{
|
||||||
|
selectPackage.IgnoreRuleName = evt.newValue.ClassName;
|
||||||
|
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_setting2Container.Add(_ignoreRulePopupField);
|
||||||
|
}
|
||||||
|
|
||||||
// 配置修复按钮
|
// 配置修复按钮
|
||||||
var fixBtn = root.Q<Button>("FixButton");
|
var fixBtn = root.Q<Button>("FixButton");
|
||||||
|
@ -475,8 +485,8 @@ namespace YooAsset.Editor
|
||||||
_enableAddressableToogle.SetValueWithoutNotify(selectPackage.EnableAddressable);
|
_enableAddressableToogle.SetValueWithoutNotify(selectPackage.EnableAddressable);
|
||||||
_locationToLowerToogle.SetValueWithoutNotify(selectPackage.LocationToLower);
|
_locationToLowerToogle.SetValueWithoutNotify(selectPackage.LocationToLower);
|
||||||
_includeAssetGUIDToogle.SetValueWithoutNotify(selectPackage.IncludeAssetGUID);
|
_includeAssetGUIDToogle.SetValueWithoutNotify(selectPackage.IncludeAssetGUID);
|
||||||
_ignoreDefaultTypeToogle.SetValueWithoutNotify(selectPackage.IgnoreDefaultType);
|
|
||||||
_autoCollectShadersToogle.SetValueWithoutNotify(selectPackage.AutoCollectShaders);
|
_autoCollectShadersToogle.SetValueWithoutNotify(selectPackage.AutoCollectShaders);
|
||||||
|
_ignoreRulePopupField.SetValueWithoutNotify(GetIgnoreRuleIndex(selectPackage.IgnoreRuleName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -980,14 +990,15 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
||||||
CollectCommand command = new CollectCommand(EBuildMode.SimulateBuild,
|
CollectCommand command = new CollectCommand(EBuildMode.SimulateBuild,
|
||||||
_packageNameTxt.value,
|
_packageNameTxt.value,
|
||||||
_enableAddressableToogle.value,
|
_enableAddressableToogle.value,
|
||||||
_locationToLowerToogle.value,
|
_locationToLowerToogle.value,
|
||||||
_includeAssetGUIDToogle.value,
|
_includeAssetGUIDToogle.value,
|
||||||
_ignoreDefaultTypeToogle.value,
|
|
||||||
_autoCollectShadersToogle.value,
|
_autoCollectShadersToogle.value,
|
||||||
_uniqueBundleNameToogle.value);
|
_uniqueBundleNameToogle.value,
|
||||||
|
ignoreRule);
|
||||||
collector.CheckConfigError();
|
collector.CheckConfigError();
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
}
|
}
|
||||||
|
@ -1078,6 +1089,15 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
private RuleDisplayName GetIgnoreRuleIndex(string ruleName)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _ignoreRuleList.Count; i++)
|
||||||
|
{
|
||||||
|
if (_ignoreRuleList[i].ClassName == ruleName)
|
||||||
|
return _ignoreRuleList[i];
|
||||||
|
}
|
||||||
|
return _ignoreRuleList[0];
|
||||||
|
}
|
||||||
private RuleDisplayName GetActiveRuleIndex(string ruleName)
|
private RuleDisplayName GetActiveRuleIndex(string ruleName)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _activeRuleList.Count; i++)
|
for (int i = 0; i < _activeRuleList.Count; i++)
|
||||||
|
|
|
@ -13,11 +13,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageName { private set; get; }
|
public string PackageName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 忽略Unity引擎无法识别的文件
|
|
||||||
/// </summary>
|
|
||||||
public bool IgnoreDefaultType { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用可寻址资源定位
|
/// 启用可寻址资源定位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -48,17 +43,24 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ShadersBundleName { private set; get; }
|
public string ShadersBundleName { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 忽略规则实例
|
||||||
|
/// </summary>
|
||||||
|
public IIgnoreRule IgnoreRule { private set; get; }
|
||||||
|
|
||||||
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool locationToLower, bool includeAssetGUID, bool ignoreDefaultType, bool autoCollectShaders, bool uniqueBundleName)
|
|
||||||
|
public CollectCommand(EBuildMode buildMode, string packageName,
|
||||||
|
bool enableAddressable, bool locationToLower, bool includeAssetGUID,
|
||||||
|
bool autoCollectShaders, bool uniqueBundleName, IIgnoreRule ignoreRule)
|
||||||
{
|
{
|
||||||
BuildMode = buildMode;
|
BuildMode = buildMode;
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
EnableAddressable = enableAddressable;
|
EnableAddressable = enableAddressable;
|
||||||
LocationToLower = locationToLower;
|
LocationToLower = locationToLower;
|
||||||
IncludeAssetGUID = includeAssetGUID;
|
IncludeAssetGUID = includeAssetGUID;
|
||||||
IgnoreDefaultType = ignoreDefaultType;
|
|
||||||
AutoCollectShaders = autoCollectShaders;
|
AutoCollectShaders = autoCollectShaders;
|
||||||
UniqueBundleName = uniqueBundleName;
|
UniqueBundleName = uniqueBundleName;
|
||||||
|
IgnoreRule = ignoreRule;
|
||||||
|
|
||||||
// 着色器统一全名称
|
// 着色器统一全名称
|
||||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源忽略规则接口
|
||||||
|
/// </summary>
|
||||||
|
public interface IIgnoreRule
|
||||||
|
{
|
||||||
|
bool IsIgnore(AssetInfo assetInfo);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bd55753dbb880fa449bf4e37b33d8ba7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -6,22 +6,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class DefaultFilterRule
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 忽略的文件类型
|
|
||||||
/// </summary>
|
|
||||||
private readonly static HashSet<string> _ignoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询是否为忽略文件
|
|
||||||
/// </summary>
|
|
||||||
public static bool IsIgnoreFile(string fileExtension)
|
|
||||||
{
|
|
||||||
return _ignoreFileExtensions.Contains(fileExtension);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[DisplayName("收集所有资源")]
|
[DisplayName("收集所有资源")]
|
||||||
public class CollectAll : IFilterRule
|
public class CollectAll : IFilterRule
|
||||||
{
|
{
|
||||||
|
@ -69,7 +53,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("收集着色器")]
|
[DisplayName("收集着色器")]
|
||||||
public class CollectShader : IFilterRule
|
public class CollectShader : IFilterRule
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class DefaultIgnoreRule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 忽略的文件类型
|
||||||
|
/// </summary>
|
||||||
|
public readonly static HashSet<string> IgnoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 适配常规的资源构建管线
|
||||||
|
/// </summary>
|
||||||
|
public class NormalIgnoreRule : IIgnoreRule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 查询是否为忽略文件
|
||||||
|
/// </summary>
|
||||||
|
public bool IsIgnore(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
if (assetInfo.AssetPath.StartsWith("Assets/") == false && assetInfo.AssetPath.StartsWith("Packages/") == false)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogError($"Invalid asset path : {assetInfo.AssetPath}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 忽略文件夹
|
||||||
|
if (AssetDatabase.IsValidFolder(assetInfo.AssetPath))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// 忽略编辑器下的类型资源
|
||||||
|
if (assetInfo.AssetType == typeof(LightingDataAsset))
|
||||||
|
return true;
|
||||||
|
if (assetInfo.AssetType == typeof(LightmapParameters))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// 忽略Unity引擎无法识别的文件
|
||||||
|
if (assetInfo.AssetType == typeof(UnityEditor.DefaultAsset))
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetInfo.AssetPath}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefaultIgnoreRule.IgnoreFileExtensions.Contains(assetInfo.FileExtension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 适配原生文件构建管线
|
||||||
|
/// </summary>
|
||||||
|
public class RawFileIgnoreRule : IIgnoreRule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 查询是否为忽略文件
|
||||||
|
/// </summary>
|
||||||
|
public bool IsIgnore(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
if (assetInfo.AssetPath.StartsWith("Assets/") == false && assetInfo.AssetPath.StartsWith("Packages/") == false)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogError($"Invalid asset path : {assetInfo.AssetPath}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 忽略文件夹
|
||||||
|
if (AssetDatabase.IsValidFolder(assetInfo.AssetPath))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// 忽略编辑器下的类型资源
|
||||||
|
if (assetInfo.AssetType == typeof(LightingDataAsset))
|
||||||
|
return true;
|
||||||
|
if (assetInfo.AssetType == typeof(LightmapParameters))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return DefaultIgnoreRule.IgnoreFileExtensions.Contains(assetInfo.FileExtension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b9c1900577194bb4ab49ce4332ccc4bc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -58,8 +58,8 @@ namespace YooAsset.Editor
|
||||||
public bool EnableAddressable;
|
public bool EnableAddressable;
|
||||||
public bool LocationToLower;
|
public bool LocationToLower;
|
||||||
public bool IncludeAssetGUID;
|
public bool IncludeAssetGUID;
|
||||||
public bool IgnoreDefaultType;
|
|
||||||
public bool AutoCollectShaders;
|
public bool AutoCollectShaders;
|
||||||
|
public string IgnoreRuleName;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
public bool EnableSharePackRule;
|
public bool EnableSharePackRule;
|
||||||
|
|
|
@ -72,8 +72,8 @@ namespace YooAsset.Editor
|
||||||
_items.Add(new ItemWrapper("Enable Addressable", $"{buildReport.Summary.EnableAddressable}"));
|
_items.Add(new ItemWrapper("Enable Addressable", $"{buildReport.Summary.EnableAddressable}"));
|
||||||
_items.Add(new ItemWrapper("Location To Lower", $"{buildReport.Summary.LocationToLower}"));
|
_items.Add(new ItemWrapper("Location To Lower", $"{buildReport.Summary.LocationToLower}"));
|
||||||
_items.Add(new ItemWrapper("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}"));
|
_items.Add(new ItemWrapper("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}"));
|
||||||
_items.Add(new ItemWrapper("Ignore Default Type", $"{buildReport.Summary.IgnoreDefaultType}"));
|
|
||||||
_items.Add(new ItemWrapper("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}"));
|
_items.Add(new ItemWrapper("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}"));
|
||||||
|
_items.Add(new ItemWrapper("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}"));
|
||||||
|
|
||||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||||
_items.Add(new ItemWrapper("Build Params", string.Empty));
|
_items.Add(new ItemWrapper("Build Params", string.Empty));
|
||||||
|
|
Loading…
Reference in New Issue