parent
00ffd55fef
commit
5c02bc2bee
|
@ -29,7 +29,7 @@ namespace YooAsset.Editor
|
||||||
private PopupField<string> _encryptionField;
|
private PopupField<string> _encryptionField;
|
||||||
private EnumField _compressionField;
|
private EnumField _compressionField;
|
||||||
private Toggle _appendExtensionToggle;
|
private Toggle _appendExtensionToggle;
|
||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -40,7 +40,7 @@ namespace YooAsset.Editor
|
||||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleBuilderWindow>();
|
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleBuilderWindow>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
visualAsset.CloneTree(root);
|
visualAsset.CloneTree(root);
|
||||||
|
|
||||||
_buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
_buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
|
@ -107,7 +107,7 @@ namespace YooAsset.Editor
|
||||||
_compressionField = root.Q<EnumField>("Compression");
|
_compressionField = root.Q<EnumField>("Compression");
|
||||||
_compressionField.Init(AssetBundleBuilderSettingData.Setting.CompressOption);
|
_compressionField.Init(AssetBundleBuilderSettingData.Setting.CompressOption);
|
||||||
_compressionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CompressOption);
|
_compressionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CompressOption);
|
||||||
_compressionField.style.width = 300;
|
_compressionField.style.width = 300;
|
||||||
_compressionField.RegisterValueChangedCallback(evt =>
|
_compressionField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value;
|
AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value;
|
||||||
|
@ -183,11 +183,10 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
bool succeed = builder.Run(buildParameters);
|
bool succeed = builder.Run(buildParameters);
|
||||||
|
|
||||||
if (succeed)
|
if (succeed)
|
||||||
{
|
{
|
||||||
EditorUtility.RevealInFinder($"{buildParameters.OutputRoot}/{buildParameters.BuildTarget}/{buildParameters.BuildVersion}");
|
EditorUtility.RevealInFinder($"{buildParameters.OutputRoot}/{buildParameters.BuildTarget}/{buildParameters.BuildVersion}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加密类相关
|
// 加密类相关
|
||||||
|
|
|
@ -25,6 +25,11 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetTags = string.Empty;
|
public string AssetTags = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分组激活规则
|
||||||
|
/// </summary>
|
||||||
|
public string ActiveRuleName = nameof(EnableGroup);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组的收集器列表
|
/// 分组的收集器列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -36,6 +41,9 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CheckConfigError()
|
public void CheckConfigError()
|
||||||
{
|
{
|
||||||
|
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
|
||||||
|
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
|
||||||
|
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
collector.CheckConfigError();
|
collector.CheckConfigError();
|
||||||
|
@ -49,6 +57,13 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||||
|
|
||||||
|
// 检测分组是否激活
|
||||||
|
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||||
|
if (activeRule.IsActiveGroup() == false)
|
||||||
|
{
|
||||||
|
return new List<CollectAssetInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,9 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleCollectorSettingData
|
public class AssetBundleCollectorSettingData
|
||||||
{
|
{
|
||||||
|
private static readonly Dictionary<string, System.Type> _cacheActiveRuleTypes = new Dictionary<string, Type>();
|
||||||
|
private static readonly Dictionary<string, IActiveRule> _cacheActiveRuleInstance = new Dictionary<string, IActiveRule>();
|
||||||
|
|
||||||
private static readonly Dictionary<string, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>();
|
private static readonly Dictionary<string, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>();
|
||||||
private static readonly Dictionary<string, IAddressRule> _cacheAddressRuleInstance = new Dictionary<string, IAddressRule>();
|
private static readonly Dictionary<string, IAddressRule> _cacheAddressRuleInstance = new Dictionary<string, IAddressRule>();
|
||||||
|
|
||||||
|
@ -35,6 +38,18 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<string> GetActiveRuleNames()
|
||||||
|
{
|
||||||
|
if (_setting == null)
|
||||||
|
LoadSettingData();
|
||||||
|
|
||||||
|
List<string> names = new List<string>();
|
||||||
|
foreach (var pair in _cacheActiveRuleTypes)
|
||||||
|
{
|
||||||
|
names.Add(pair.Key);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
public static List<string> GetAddressRuleNames()
|
public static List<string> GetAddressRuleNames()
|
||||||
{
|
{
|
||||||
if (_setting == null)
|
if (_setting == null)
|
||||||
|
@ -71,6 +86,15 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
public static bool HasActiveRuleName(string ruleName)
|
||||||
|
{
|
||||||
|
foreach (var pair in _cacheActiveRuleTypes)
|
||||||
|
{
|
||||||
|
if (pair.Key == ruleName)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public static bool HasAddressRuleName(string ruleName)
|
public static bool HasAddressRuleName(string ruleName)
|
||||||
{
|
{
|
||||||
foreach (var pair in _cacheAddressRuleTypes)
|
foreach (var pair in _cacheAddressRuleTypes)
|
||||||
|
@ -182,6 +206,29 @@ namespace YooAsset.Editor
|
||||||
_cacheAddressRuleTypes.Add(type.Name, type);
|
_cacheAddressRuleTypes.Add(type.Name, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IActiveRule
|
||||||
|
{
|
||||||
|
// 清空缓存集合
|
||||||
|
_cacheActiveRuleTypes.Clear();
|
||||||
|
_cacheActiveRuleInstance.Clear();
|
||||||
|
|
||||||
|
// 获取所有类型
|
||||||
|
List<Type> types = new List<Type>(100)
|
||||||
|
{
|
||||||
|
typeof(EnableGroup),
|
||||||
|
typeof(DisableGroup),
|
||||||
|
};
|
||||||
|
|
||||||
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IActiveRule));
|
||||||
|
types.AddRange(customTypes);
|
||||||
|
for (int i = 0; i < types.Count; i++)
|
||||||
|
{
|
||||||
|
Type type = types[i];
|
||||||
|
if (_cacheActiveRuleTypes.ContainsKey(type.Name) == false)
|
||||||
|
_cacheActiveRuleTypes.Add(type.Name, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -210,6 +257,23 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 实例类相关
|
// 实例类相关
|
||||||
|
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
||||||
|
{
|
||||||
|
if (_cacheActiveRuleInstance.TryGetValue(ruleName, out IActiveRule instance))
|
||||||
|
return instance;
|
||||||
|
|
||||||
|
// 如果不存在创建类的实例
|
||||||
|
if (_cacheActiveRuleTypes.TryGetValue(ruleName, out Type type))
|
||||||
|
{
|
||||||
|
instance = (IActiveRule)Activator.CreateInstance(type);
|
||||||
|
_cacheActiveRuleInstance.Add(ruleName, instance);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{nameof(IActiveRule)}类型无效:{ruleName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
public static IAddressRule GetAddressRuleInstance(string ruleName)
|
public static IAddressRule GetAddressRuleInstance(string ruleName)
|
||||||
{
|
{
|
||||||
if (_cacheAddressRuleInstance.TryGetValue(ruleName, out IAddressRule instance))
|
if (_cacheAddressRuleInstance.TryGetValue(ruleName, out IAddressRule instance))
|
||||||
|
|
|
@ -19,11 +19,13 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> _collectorTypeList;
|
private List<string> _collectorTypeList;
|
||||||
|
private List<string> _activeRuleList;
|
||||||
private List<string> _addressRuleList;
|
private List<string> _addressRuleList;
|
||||||
private List<string> _packRuleList;
|
private List<string> _packRuleList;
|
||||||
private List<string> _filterRuleList;
|
private List<string> _filterRuleList;
|
||||||
private ListView _groupListView;
|
private ListView _groupListView;
|
||||||
private ScrollView _collectorScrollView;
|
private ScrollView _collectorScrollView;
|
||||||
|
private PopupField<string> _activeRulePopupField;
|
||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
private Toggle _autoCollectShaderToogle;
|
private Toggle _autoCollectShaderToogle;
|
||||||
private TextField _shaderBundleNameTxt;
|
private TextField _shaderBundleNameTxt;
|
||||||
|
@ -47,6 +49,7 @@ namespace YooAsset.Editor
|
||||||
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
||||||
$"{nameof(ECollectorType.DependAssetCollector)}"
|
$"{nameof(ECollectorType.DependAssetCollector)}"
|
||||||
};
|
};
|
||||||
|
_activeRuleList = AssetBundleCollectorSettingData.GetActiveRuleNames();
|
||||||
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
||||||
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
||||||
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
||||||
|
@ -57,7 +60,7 @@ namespace YooAsset.Editor
|
||||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleCollectorWindow>();
|
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleCollectorWindow>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
visualAsset.CloneTree(root);
|
visualAsset.CloneTree(root);
|
||||||
|
|
||||||
// 导入导出按钮
|
// 导入导出按钮
|
||||||
|
@ -155,6 +158,25 @@ namespace YooAsset.Editor
|
||||||
addBtn.clicked += AddCollectorBtn_clicked;
|
addBtn.clicked += AddCollectorBtn_clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分组激活规则
|
||||||
|
var activeRuleContainer = root.Q("ActiveRuleContainer");
|
||||||
|
{
|
||||||
|
_activeRulePopupField = new PopupField<string>("Active Rule", _activeRuleList, 0);
|
||||||
|
_activeRulePopupField.name = "ActiveRuleMaskField";
|
||||||
|
_activeRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
activeRuleContainer.Add(_activeRulePopupField);
|
||||||
|
_activeRulePopupField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||||
|
if (selectGroup != null)
|
||||||
|
{
|
||||||
|
selectGroup.ActiveRuleName = evt.newValue;
|
||||||
|
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||||
|
FillGroupViewData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 刷新窗体
|
// 刷新窗体
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
|
@ -243,6 +265,11 @@ namespace YooAsset.Editor
|
||||||
textField1.text = group.GroupName;
|
textField1.text = group.GroupName;
|
||||||
else
|
else
|
||||||
textField1.text = $"{group.GroupName} ({group.GroupDesc})";
|
textField1.text = $"{group.GroupName} ({group.GroupDesc})";
|
||||||
|
|
||||||
|
// 激活状态
|
||||||
|
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(group.ActiveRuleName);
|
||||||
|
bool isActive = activeRule.IsActiveGroup();
|
||||||
|
textField1.SetEnabled(isActive);
|
||||||
}
|
}
|
||||||
private void GroupListView_onSelectionChange(IEnumerable<object> objs)
|
private void GroupListView_onSelectionChange(IEnumerable<object> objs)
|
||||||
{
|
{
|
||||||
|
@ -277,6 +304,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
_lastModifyGroup = selectGroup.GroupName;
|
_lastModifyGroup = selectGroup.GroupName;
|
||||||
_groupContainer.visible = true;
|
_groupContainer.visible = true;
|
||||||
|
_activeRulePopupField.SetValueWithoutNotify(selectGroup.ActiveRuleName);
|
||||||
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
|
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
|
||||||
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
|
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
|
||||||
_groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
|
_groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<ui:TextField picking-mode="Ignore" label="Shader Bundle Name" name="ShaderBundleName" style="flex-grow: 1; -unity-text-align: middle-left;" />
|
<ui:TextField picking-mode="Ignore" label="Shader Bundle Name" name="ShaderBundleName" style="flex-grow: 1; -unity-text-align: middle-left;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="GroupContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
<ui:VisualElement name="GroupContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
|
<ui:VisualElement name="ActiveRuleContainer" style="height: 20px;" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Group Name" name="GroupName" />
|
<ui:TextField picking-mode="Ignore" label="Group Name" name="GroupName" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" />
|
<ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Group Asset Tags" name="GroupAssetTags" />
|
<ui:TextField picking-mode="Ignore" label="Group Asset Tags" name="GroupAssetTags" />
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 启用分组
|
||||||
|
/// </summary>
|
||||||
|
public class EnableGroup : IActiveRule
|
||||||
|
{
|
||||||
|
public bool IsActiveGroup()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 禁用分组
|
||||||
|
/// </summary>
|
||||||
|
public class DisableGroup : IActiveRule
|
||||||
|
{
|
||||||
|
public bool IsActiveGroup()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2cfd65b3b7663b247b2df16077f4ef17
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源分组激活规则接口
|
||||||
|
/// </summary>
|
||||||
|
public interface IActiveRule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否激活分组
|
||||||
|
/// </summary>
|
||||||
|
bool IsActiveGroup();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: aed5a1a6733b7d44ca4f6149ed5a2bb8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue