mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
升级YooAsset->2.1.1、UniTask->2.5.4
升级YooAsset->2.1.1、UniTask->2.5.4
This commit is contained in:
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
||||
public static class AssetBundleBuilderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取默认的输出根路录
|
||||
/// 获取默认的输出根目录
|
||||
/// </summary>
|
||||
public static string GetDefaultBuildOutputRoot()
|
||||
{
|
||||
|
@@ -37,7 +37,7 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
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;
|
||||
|
||||
// 构建参数
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -18,7 +18,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ִ<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -20,7 +20,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ִ<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
|
@@ -166,7 +166,7 @@ namespace YooAsset.Editor
|
||||
foreach (string assetPath in findAssets)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -228,37 +228,6 @@ namespace YooAsset.Editor
|
||||
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)
|
||||
{
|
||||
// 根据规则设置过滤资源文件
|
||||
@@ -312,7 +281,7 @@ namespace YooAsset.Editor
|
||||
continue;
|
||||
|
||||
AssetInfo assetInfo = new AssetInfo(assetPath);
|
||||
if (IsValidateAsset(command, assetInfo))
|
||||
if (command.IgnoreRule.IsIgnore(assetInfo) == false)
|
||||
result.Add(assetInfo);
|
||||
}
|
||||
return result;
|
||||
|
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleCollectorConfig
|
||||
{
|
||||
public const string ConfigVersion = "v2.0.0";
|
||||
public const string ConfigVersion = "v2.1";
|
||||
|
||||
public const string XmlVersion = "Version";
|
||||
public const string XmlCommon = "Common";
|
||||
@@ -25,7 +25,7 @@ namespace YooAsset.Editor
|
||||
public const string XmlEnableAddressable = "AutoAddressable";
|
||||
public const string XmlLocationToLower = "LocationToLower";
|
||||
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
||||
public const string XmlIgnoreDefaultType = "IgnoreDefaultType";
|
||||
public const string XmlIgnoreRuleName = "IgnoreRuleName";
|
||||
|
||||
public const string XmlGroup = "Group";
|
||||
public const string XmlGroupActiveRule = "GroupActiveRule";
|
||||
@@ -101,7 +101,7 @@ namespace YooAsset.Editor
|
||||
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "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);
|
||||
|
||||
// 读取分组配置
|
||||
@@ -213,7 +213,7 @@ namespace YooAsset.Editor
|
||||
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
||||
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
||||
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
||||
packageElement.SetAttribute(XmlIgnoreDefaultType, package.IgnoreDefaultType.ToString());
|
||||
packageElement.SetAttribute(XmlIgnoreRuleName, package.IgnoreRuleName);
|
||||
root.AppendChild(packageElement);
|
||||
|
||||
// 设置分组配置
|
||||
@@ -258,6 +258,23 @@ namespace YooAsset.Editor
|
||||
if (configVersion == ConfigVersion)
|
||||
return true;
|
||||
|
||||
// v2.0.0 -> v2.1
|
||||
if (configVersion == "v2.0.0")
|
||||
{
|
||||
// 读取包裹配置
|
||||
var packageNodeList = root.GetElementsByTagName(XmlPackage);
|
||||
foreach (var packageNode in packageNodeList)
|
||||
{
|
||||
XmlElement packageElement = packageNode as XmlElement;
|
||||
if (packageElement.HasAttribute(XmlIgnoreRuleName) == false)
|
||||
packageElement.SetAttribute(XmlIgnoreRuleName, nameof(NormalIgnoreRule));
|
||||
}
|
||||
|
||||
// 更新版本
|
||||
root.SetAttribute(XmlVersion, "v2.1");
|
||||
return UpdateXmlConfig(xmlDoc);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -35,16 +35,16 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool IncludeAssetGUID = false;
|
||||
|
||||
/// <summary>
|
||||
/// 忽略Unity引擎无法识别的文件
|
||||
/// </summary>
|
||||
public bool IgnoreDefaultType = true;
|
||||
|
||||
/// <summary>
|
||||
/// 自动收集所有着色器(所有着色器存储在一个资源包内)
|
||||
/// </summary>
|
||||
public bool AutoCollectShaders = true;
|
||||
|
||||
/// <summary>
|
||||
/// 资源忽略规则名
|
||||
/// </summary>
|
||||
public string IgnoreRuleName = nameof(NormalIgnoreRule);
|
||||
|
||||
/// <summary>
|
||||
/// 分组列表
|
||||
/// </summary>
|
||||
@@ -56,6 +56,16 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
if (string.IsNullOrEmpty(IgnoreRuleName))
|
||||
{
|
||||
throw new Exception($"{nameof(IgnoreRuleName)} is null or empty !");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AssetBundleCollectorSettingData.HasIgnoreRuleName(IgnoreRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IIgnoreRule)} class type : {IgnoreRuleName} in package : {PackageName}");
|
||||
}
|
||||
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
group.CheckConfigError();
|
||||
@@ -68,6 +78,14 @@ namespace YooAsset.Editor
|
||||
public bool FixConfigError()
|
||||
{
|
||||
bool isFixed = false;
|
||||
|
||||
if (string.IsNullOrEmpty(IgnoreRuleName))
|
||||
{
|
||||
Debug.LogWarning($"Set the {nameof(IgnoreRuleName)} to {nameof(NormalIgnoreRule)}");
|
||||
IgnoreRuleName = nameof(NormalIgnoreRule);
|
||||
isFixed = true;
|
||||
}
|
||||
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
if (group.FixConfigError())
|
||||
@@ -75,6 +93,7 @@ namespace YooAsset.Editor
|
||||
isFixed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return isFixed;
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,6 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool UniqueBundleName = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 包裹列表
|
||||
/// </summary>
|
||||
@@ -100,13 +99,13 @@ namespace YooAsset.Editor
|
||||
package.CheckConfigError();
|
||||
|
||||
// 创建资源收集命令
|
||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(package.IgnoreRuleName);
|
||||
CollectCommand command = new CollectCommand(buildMode, packageName,
|
||||
package.EnableAddressable,
|
||||
package.LocationToLower,
|
||||
package.IncludeAssetGUID,
|
||||
package.IgnoreDefaultType,
|
||||
package.AutoCollectShaders,
|
||||
UniqueBundleName);
|
||||
UniqueBundleName, ignoreRule);
|
||||
|
||||
// 获取收集的资源集合
|
||||
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, 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>
|
||||
@@ -129,6 +132,29 @@ namespace YooAsset.Editor
|
||||
_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;
|
||||
@@ -165,6 +191,7 @@ namespace YooAsset.Editor
|
||||
if (isFixed)
|
||||
{
|
||||
IsDirty = true;
|
||||
Debug.Log("Fix package config error done !");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,6 +252,18 @@ namespace YooAsset.Editor
|
||||
}
|
||||
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)
|
||||
{
|
||||
var attribute = DisplayNameAttributeHelper.GetAttribute<DisplayNameAttribute>(type);
|
||||
@@ -250,6 +289,10 @@ namespace YooAsset.Editor
|
||||
{
|
||||
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
|
||||
}
|
||||
public static bool HasIgnoreRuleName(string ruleName)
|
||||
{
|
||||
return _cacheIgnoreRuleTypes.Keys.Contains(ruleName);
|
||||
}
|
||||
|
||||
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
||||
{
|
||||
@@ -319,6 +362,23 @@ namespace YooAsset.Editor
|
||||
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)
|
||||
|
@@ -24,6 +24,7 @@ namespace YooAsset.Editor
|
||||
private List<RuleDisplayName> _addressRuleList;
|
||||
private List<RuleDisplayName> _packRuleList;
|
||||
private List<RuleDisplayName> _filterRuleList;
|
||||
private List<RuleDisplayName> _ignoreRuleList;
|
||||
|
||||
private VisualElement _helpBoxContainer;
|
||||
|
||||
@@ -39,9 +40,9 @@ namespace YooAsset.Editor
|
||||
private Toggle _enableAddressableToogle;
|
||||
private Toggle _locationToLowerToogle;
|
||||
private Toggle _includeAssetGUIDToogle;
|
||||
private Toggle _ignoreDefaultTypeToogle;
|
||||
private Toggle _autoCollectShadersToogle;
|
||||
|
||||
private PopupField<RuleDisplayName> _ignoreRulePopupField;
|
||||
|
||||
private VisualElement _packageContainer;
|
||||
private ListView _packageListView;
|
||||
private TextField _packageNameTxt;
|
||||
@@ -77,6 +78,7 @@ namespace YooAsset.Editor
|
||||
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
||||
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
||||
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
||||
_ignoreRuleList = AssetBundleCollectorSettingData.GetIgnoreRuleNames();
|
||||
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
@@ -151,17 +153,6 @@ namespace YooAsset.Editor
|
||||
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.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
@@ -173,6 +164,25 @@ namespace YooAsset.Editor
|
||||
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");
|
||||
@@ -475,8 +485,8 @@ namespace YooAsset.Editor
|
||||
_enableAddressableToogle.SetValueWithoutNotify(selectPackage.EnableAddressable);
|
||||
_locationToLowerToogle.SetValueWithoutNotify(selectPackage.LocationToLower);
|
||||
_includeAssetGUIDToogle.SetValueWithoutNotify(selectPackage.IncludeAssetGUID);
|
||||
_ignoreDefaultTypeToogle.SetValueWithoutNotify(selectPackage.IgnoreDefaultType);
|
||||
_autoCollectShadersToogle.SetValueWithoutNotify(selectPackage.AutoCollectShaders);
|
||||
_ignoreRulePopupField.SetValueWithoutNotify(GetIgnoreRuleIndex(selectPackage.IgnoreRuleName));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -970,7 +980,7 @@ namespace YooAsset.Editor
|
||||
|
||||
if (collector.IsValid() == false)
|
||||
{
|
||||
Debug.LogWarning($"The collector is invalid : {collector.CollectPath} in group : {group.GroupName}");
|
||||
collector.CheckConfigError();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -980,14 +990,15 @@ namespace YooAsset.Editor
|
||||
|
||||
try
|
||||
{
|
||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
||||
CollectCommand command = new CollectCommand(EBuildMode.SimulateBuild,
|
||||
_packageNameTxt.value,
|
||||
_enableAddressableToogle.value,
|
||||
_locationToLowerToogle.value,
|
||||
_includeAssetGUIDToogle.value,
|
||||
_ignoreDefaultTypeToogle.value,
|
||||
_autoCollectShadersToogle.value,
|
||||
_uniqueBundleNameToogle.value);
|
||||
_uniqueBundleNameToogle.value,
|
||||
ignoreRule);
|
||||
collector.CheckConfigError();
|
||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||
}
|
||||
@@ -1078,6 +1089,15 @@ namespace YooAsset.Editor
|
||||
}
|
||||
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)
|
||||
{
|
||||
for (int i = 0; i < _activeRuleList.Count; i++)
|
||||
|
@@ -21,7 +21,6 @@
|
||||
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Ignore Default Type" name="IgnoreDefaultType" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Auto Collect Shaders" name="AutoCollectShaders" value="true" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
|
@@ -13,11 +13,6 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string PackageName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 忽略Unity引擎无法识别的文件
|
||||
/// </summary>
|
||||
public bool IgnoreDefaultType { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
@@ -48,17 +43,24 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
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;
|
||||
PackageName = packageName;
|
||||
EnableAddressable = enableAddressable;
|
||||
LocationToLower = locationToLower;
|
||||
IncludeAssetGUID = includeAssetGUID;
|
||||
IgnoreDefaultType = ignoreDefaultType;
|
||||
AutoCollectShaders = autoCollectShaders;
|
||||
UniqueBundleName = uniqueBundleName;
|
||||
IgnoreRule = ignoreRule;
|
||||
|
||||
// 着色器统一全名称
|
||||
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
|
||||
{
|
||||
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("收集所有资源")]
|
||||
public class CollectAll : IFilterRule
|
||||
{
|
||||
@@ -70,6 +54,15 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("收集着色器")]
|
||||
public class CollectShader : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".shader";
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("收集着色器变种集合")]
|
||||
public class CollectShaderVariants : 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:
|
@@ -147,6 +147,18 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打包着色器
|
||||
/// </summary>
|
||||
[DisplayName("打包着色器文件")]
|
||||
public class PackShader : IPackRule
|
||||
{
|
||||
public PackRuleResult GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
return DefaultPackRule.CreateShadersPackRuleResult();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打包着色器变种集合
|
||||
/// </summary>
|
||||
|
@@ -58,8 +58,8 @@ namespace YooAsset.Editor
|
||||
public bool EnableAddressable;
|
||||
public bool LocationToLower;
|
||||
public bool IncludeAssetGUID;
|
||||
public bool IgnoreDefaultType;
|
||||
public bool AutoCollectShaders;
|
||||
public string IgnoreRuleName;
|
||||
|
||||
// 构建参数
|
||||
public bool EnableSharePackRule;
|
||||
|
@@ -72,8 +72,8 @@ namespace YooAsset.Editor
|
||||
_items.Add(new ItemWrapper("Enable Addressable", $"{buildReport.Summary.EnableAddressable}"));
|
||||
_items.Add(new ItemWrapper("Location To Lower", $"{buildReport.Summary.LocationToLower}"));
|
||||
_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("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}"));
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("Build Params", string.Empty));
|
||||
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07a483743a0f68e4cb55a38570d1b7cd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user