commit
32643caf51
|
@ -17,6 +17,7 @@ namespace YooAsset.Editor
|
|||
public const string XmlEnableAddressable = "AutoAddressable";
|
||||
public const string XmlUniqueBundleName = "UniqueBundleName";
|
||||
public const string XmlShowPackageView = "ShowPackageView";
|
||||
public const string XmlShowEditorAlias = "ShowEditorAlias";
|
||||
|
||||
public const string XmlPackage = "Package";
|
||||
public const string XmlPackageName = "PackageName";
|
||||
|
@ -65,6 +66,7 @@ namespace YooAsset.Editor
|
|||
bool enableAddressable = false;
|
||||
bool uniqueBundleName = false;
|
||||
bool showPackageView = false;
|
||||
bool showEditorAlias = false;
|
||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||
if (commonNodeList.Count > 0)
|
||||
{
|
||||
|
@ -79,6 +81,7 @@ namespace YooAsset.Editor
|
|||
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
||||
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
||||
showEditorAlias = commonElement.GetAttribute(XmlShowEditorAlias) == "True" ? true : false;
|
||||
}
|
||||
|
||||
// 读取包裹配置
|
||||
|
@ -153,6 +156,7 @@ namespace YooAsset.Editor
|
|||
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
||||
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
|
||||
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
||||
AssetBundleCollectorSettingData.Setting.ShowEditorAlias = showEditorAlias;
|
||||
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
Debug.Log($"导入配置完毕!");
|
||||
|
@ -183,6 +187,7 @@ namespace YooAsset.Editor
|
|||
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
||||
commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString());
|
||||
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
||||
commonElement.SetAttribute(XmlShowEditorAlias, AssetBundleCollectorSettingData.Setting.ShowEditorAlias.ToString());
|
||||
root.AppendChild(commonElement);
|
||||
|
||||
// 设置Package配置
|
||||
|
|
|
@ -23,6 +23,12 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public bool UniqueBundleName = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示编辑器别名
|
||||
/// </summary>
|
||||
public bool ShowEditorAlias = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 包裹列表
|
||||
/// </summary>
|
||||
|
|
|
@ -38,6 +38,22 @@ namespace YooAsset.Editor
|
|||
}
|
||||
}
|
||||
|
||||
private static string GetEditorShowName(string name,Type type)
|
||||
{
|
||||
if (Setting != null && Setting.ShowEditorAlias)
|
||||
{
|
||||
var attr = YooAssetAttributes.GetAttribute<EditorShowAttribute>(type);
|
||||
if (attr != null && !string.IsNullOrEmpty(attr.Name))
|
||||
return attr.Name;
|
||||
else
|
||||
return name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<string> GetActiveRuleNames()
|
||||
{
|
||||
if (_setting == null)
|
||||
|
@ -47,8 +63,8 @@ namespace YooAsset.Editor
|
|||
foreach (var pair in _cacheActiveRuleTypes)
|
||||
{
|
||||
names.Add(pair.Key);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
public static List<string> GetAddressRuleNames()
|
||||
{
|
||||
|
@ -58,7 +74,7 @@ namespace YooAsset.Editor
|
|||
List<string> names = new List<string>();
|
||||
foreach (var pair in _cacheAddressRuleTypes)
|
||||
{
|
||||
names.Add(pair.Key);
|
||||
names.Add(GetEditorShowName(pair.Key, pair.Value));
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
@ -70,7 +86,7 @@ namespace YooAsset.Editor
|
|||
List<string> names = new List<string>();
|
||||
foreach (var pair in _cachePackRuleTypes)
|
||||
{
|
||||
names.Add(pair.Key);
|
||||
names.Add(GetEditorShowName(pair.Key, pair.Value));
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
@ -82,10 +98,42 @@ namespace YooAsset.Editor
|
|||
List<string> names = new List<string>();
|
||||
foreach (var pair in _cacheFilterRuleTypes)
|
||||
{
|
||||
names.Add(pair.Key);
|
||||
names.Add(GetEditorShowName(pair.Key, pair.Value));
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static string GetAddressRuleName(int index)
|
||||
{
|
||||
if (_setting == null)
|
||||
LoadSettingData();
|
||||
return GetTypesName(_cacheAddressRuleTypes, index);
|
||||
}
|
||||
|
||||
public static string GetPackRuleName(int index)
|
||||
{
|
||||
if (_setting == null)
|
||||
LoadSettingData();
|
||||
return GetTypesName(_cachePackRuleTypes, index);
|
||||
}
|
||||
|
||||
public static string GetFilterRuleName(int index)
|
||||
{
|
||||
if (_setting == null)
|
||||
LoadSettingData();
|
||||
return GetTypesName(_cacheFilterRuleTypes, index);
|
||||
}
|
||||
|
||||
static string GetTypesName(Dictionary<string, System.Type> types, int index)
|
||||
{
|
||||
|
||||
if(index >= types.Keys.Count)
|
||||
{
|
||||
throw new Exception($"Invalid GetFilterRuleName Keys.Count {types.Keys.Count} : try get index {index}");
|
||||
}
|
||||
return types.Keys.ElementAt(index);
|
||||
}
|
||||
|
||||
public static bool HasActiveRuleName(string ruleName)
|
||||
{
|
||||
foreach (var pair in _cacheActiveRuleTypes)
|
||||
|
@ -353,6 +401,12 @@ namespace YooAsset.Editor
|
|||
IsDirty = true;
|
||||
}
|
||||
|
||||
public static void ModifyShowEditorAlias(bool showAlias)
|
||||
{
|
||||
Setting.ShowEditorAlias = showAlias;
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
// 资源包裹编辑相关
|
||||
public static AssetBundleCollectorPackage CreatePackage(string packageName)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace YooAsset.Editor
|
|||
private Toggle _showPackageToogle;
|
||||
private Toggle _enableAddressableToogle;
|
||||
private Toggle _uniqueBundleNameToogle;
|
||||
private Toggle _showEditorAliasToggle;
|
||||
|
||||
private VisualElement _packageContainer;
|
||||
private ListView _packageListView;
|
||||
|
@ -57,14 +58,12 @@ namespace YooAsset.Editor
|
|||
{
|
||||
_collectorTypeList = new List<string>()
|
||||
{
|
||||
$"{nameof(ECollectorType.MainAssetCollector)}",
|
||||
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
||||
$"{nameof(ECollectorType.DependAssetCollector)}"
|
||||
};
|
||||
_activeRuleList = AssetBundleCollectorSettingData.GetActiveRuleNames();
|
||||
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
||||
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
||||
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
||||
$"{nameof(ECollectorType.MainAssetCollector)}",
|
||||
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
||||
$"{nameof(ECollectorType.DependAssetCollector)}"
|
||||
};
|
||||
|
||||
RefreshNames();
|
||||
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
|
@ -95,6 +94,14 @@ namespace YooAsset.Editor
|
|||
RefreshWindow();
|
||||
});
|
||||
|
||||
_showEditorAliasToggle = root.Q<Toggle>("ShowEditorAlias");
|
||||
_showEditorAliasToggle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleCollectorSettingData.ModifyShowEditorAlias(evt.newValue);
|
||||
RefreshNames();
|
||||
RefreshWindow();
|
||||
});
|
||||
|
||||
// 配置修复按钮
|
||||
var fixBtn = root.Q<Button>("FixButton");
|
||||
fixBtn.clicked += FixBtn_clicked;
|
||||
|
@ -286,10 +293,21 @@ namespace YooAsset.Editor
|
|||
}
|
||||
}
|
||||
|
||||
private void RefreshNames()
|
||||
{
|
||||
_activeRuleList = AssetBundleCollectorSettingData.GetActiveRuleNames();
|
||||
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
||||
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
||||
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
||||
}
|
||||
|
||||
private void RefreshWindow()
|
||||
{
|
||||
_showPackageToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowPackageView);
|
||||
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable);
|
||||
_uniqueBundleNameToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.UniqueBundleName);
|
||||
_showEditorAliasToggle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowEditorAlias);
|
||||
|
||||
_groupContainer.visible = false;
|
||||
_collectorContainer.visible = false;
|
||||
|
||||
|
@ -574,7 +592,7 @@ namespace YooAsset.Editor
|
|||
var popupField = new PopupField<string>(_packRuleList, 0);
|
||||
popupField.name = "PopupField2";
|
||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
popupField.style.width = 150;
|
||||
popupField.style.width = 230;
|
||||
elementBottom.Add(popupField);
|
||||
}
|
||||
{
|
||||
|
@ -682,7 +700,8 @@ namespace YooAsset.Editor
|
|||
popupField1.index = GetAddressRuleIndex(collector.AddressRuleName);
|
||||
popupField1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.AddressRuleName = evt.newValue;
|
||||
var target = (PopupField<string>)evt.target;
|
||||
collector.AddressRuleName = AssetBundleCollectorSettingData.GetAddressRuleName(target.index);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
|
@ -696,7 +715,8 @@ namespace YooAsset.Editor
|
|||
popupField2.index = GetPackRuleIndex(collector.PackRuleName);
|
||||
popupField2.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.PackRuleName = evt.newValue;
|
||||
var target = (PopupField<string>)evt.target;
|
||||
collector.PackRuleName = AssetBundleCollectorSettingData.GetPackRuleName(target.index);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
|
@ -709,7 +729,8 @@ namespace YooAsset.Editor
|
|||
popupField3.index = GetFilterRuleIndex(collector.FilterRuleName);
|
||||
popupField3.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.FilterRuleName = evt.newValue;
|
||||
var target = (PopupField<string>)evt.target;
|
||||
collector.FilterRuleName = AssetBundleCollectorSettingData.GetFilterRuleName(target.index);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Unique Bundle Name" name="UniqueBundleName" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Show Editor Alias" name="ShowEditorAlias" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 以文件名为定位地址
|
||||
/// </summary>
|
||||
[EditorShow("以文件名为定位地址")]
|
||||
public class AddressByFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
|
@ -16,6 +17,7 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 以组名+文件名为定位地址
|
||||
/// </summary>
|
||||
[EditorShow("以组名+文件名为定位地址")]
|
||||
public class AddressByGroupAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
|
@ -28,6 +30,7 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 以收集器名+文件名为定位地址
|
||||
/// </summary>
|
||||
[EditorShow("以收集器名+文件名为定位地址")]
|
||||
public class AddressByCollectorAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 收集所有资源
|
||||
/// </summary>
|
||||
[EditorShow("收集所有资源")]
|
||||
public class CollectAll : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
|
@ -18,6 +19,7 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 只收集场景
|
||||
/// </summary>
|
||||
[EditorShow("只收集场景")]
|
||||
public class CollectScene : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
|
@ -25,10 +27,11 @@ namespace YooAsset.Editor
|
|||
return Path.GetExtension(data.AssetPath) == ".unity";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 只收集预制体
|
||||
/// </summary>
|
||||
[EditorShow("只收集预制体")]
|
||||
public class CollectPrefab : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
|
@ -40,6 +43,7 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 只收集精灵类型的资源
|
||||
/// </summary>
|
||||
[EditorShow("只收集精灵类型的资源")]
|
||||
public class CollectSprite : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
|
@ -63,6 +67,7 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 只收集着色器变种收集文件
|
||||
/// </summary>
|
||||
[EditorShow("只收集着色器变种收集文件")]
|
||||
public class CollectShaderVariants : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace YooAsset.Editor
|
|||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image_backgroud.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view_main.bundle"
|
||||
/// </summary>
|
||||
[EditorShow("以文件路径作为资源包名")]
|
||||
public class PackSeparately : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
|
@ -25,6 +26,7 @@ namespace YooAsset.Editor
|
|||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view.bundle"
|
||||
/// </summary>
|
||||
[EditorShow("以父类文件夹路径作为资源包名")]
|
||||
public class PackDirectory : IPackRule
|
||||
{
|
||||
public static PackDirectory StaticPackRule = new PackDirectory();
|
||||
|
@ -43,6 +45,7 @@ namespace YooAsset.Editor
|
|||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop.bundle"
|
||||
/// </summary>
|
||||
[EditorShow("以收集器路径下顶级文件夹为资源包名")]
|
||||
public class PackTopDirectory : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
|
@ -68,6 +71,7 @@ namespace YooAsset.Editor
|
|||
/// 以收集器路径作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
[EditorShow("以收集器路径作为资源包名")]
|
||||
public class PackCollector : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
|
@ -90,6 +94,7 @@ namespace YooAsset.Editor
|
|||
/// 以分组名称作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
[EditorShow("以分组名称作为资源包名")]
|
||||
public class PackGroup : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
|
@ -102,6 +107,7 @@ namespace YooAsset.Editor
|
|||
/// 原生文件打包模式
|
||||
/// 注意:原生文件打包支持:图片,音频,视频,文本
|
||||
/// </summary>
|
||||
[EditorShow("原生文件打包模式")]
|
||||
public class PackRawFile : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
|
@ -128,6 +134,7 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 着色器变种收集文件
|
||||
/// </summary>
|
||||
[EditorShow("着色器变种收集文件")]
|
||||
public class PackShaderVariants : IPackRule
|
||||
{
|
||||
public string GetBundleName(PackRuleData data)
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 编辑器显示名字
|
||||
/// </summary>
|
||||
internal sealed class EditorShowAttribute : Attribute
|
||||
{
|
||||
public string Name;
|
||||
public EditorShowAttribute(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
internal static class YooAssetAttributes
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取 Type 属性
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="type"></param>
|
||||
/// <returns>可能为空</returns>
|
||||
internal static T GetAttribute<T>(Type type) where T : Attribute
|
||||
{
|
||||
return (T)type.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取 MethodInfo 属性
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="methodInfo"></param>
|
||||
/// <returns>可能为空</returns>
|
||||
internal static T GetAttribute<T>(MethodInfo methodInfo) where T : Attribute
|
||||
{
|
||||
return (T)methodInfo.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取 FieldInfo 属性
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="field"></param>
|
||||
/// <returns>可能为空</returns>
|
||||
internal static T GetAttribute<T>(FieldInfo field) where T : Attribute
|
||||
{
|
||||
return (T)field.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 92d5f73b21059af43b7f56165b7acd63
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue