mirror of https://github.com/tuyoogame/YooAsset
parent
81401ca0b8
commit
32268f5a4a
|
@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleCollectorConfig
|
public class AssetBundleCollectorConfig
|
||||||
{
|
{
|
||||||
public const string ConfigVersion = "2.1";
|
public const string ConfigVersion = "2.2";
|
||||||
|
|
||||||
public const string XmlVersion = "Version";
|
public const string XmlVersion = "Version";
|
||||||
public const string XmlCommon = "Common";
|
public const string XmlCommon = "Common";
|
||||||
|
@ -77,6 +77,8 @@ namespace YooAsset.Editor
|
||||||
throw new Exception($"Not found attribute {XmlUniqueBundleName} in {XmlCommon}");
|
throw new Exception($"Not found attribute {XmlUniqueBundleName} in {XmlCommon}");
|
||||||
if (commonElement.HasAttribute(XmlShowPackageView) == false)
|
if (commonElement.HasAttribute(XmlShowPackageView) == false)
|
||||||
throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}");
|
throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}");
|
||||||
|
if (commonElement.HasAttribute(XmlShowEditorAlias) == false)
|
||||||
|
throw new Exception($"Not found attribute {XmlShowEditorAlias} in {XmlCommon}");
|
||||||
|
|
||||||
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||||
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
||||||
|
@ -301,6 +303,23 @@ namespace YooAsset.Editor
|
||||||
return UpdateXmlConfig(xmlDoc);
|
return UpdateXmlConfig(xmlDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2.1 -> 2.2
|
||||||
|
if (configVersion == "2.1")
|
||||||
|
{
|
||||||
|
// 添加公共元素属性
|
||||||
|
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||||
|
if (commonNodeList.Count > 0)
|
||||||
|
{
|
||||||
|
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||||
|
if (commonElement.HasAttribute(XmlShowEditorAlias) == false)
|
||||||
|
commonElement.SetAttribute(XmlShowEditorAlias, "False");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新版本
|
||||||
|
root.SetAttribute(XmlVersion, "2.2");
|
||||||
|
return UpdateXmlConfig(xmlDoc);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,140 +38,6 @@ 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)
|
|
||||||
LoadSettingData();
|
|
||||||
|
|
||||||
List<string> names = new List<string>();
|
|
||||||
foreach (var pair in _cacheActiveRuleTypes)
|
|
||||||
{
|
|
||||||
names.Add(pair.Key);
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
public static List<string> GetAddressRuleNames()
|
|
||||||
{
|
|
||||||
if (_setting == null)
|
|
||||||
LoadSettingData();
|
|
||||||
|
|
||||||
List<string> names = new List<string>();
|
|
||||||
foreach (var pair in _cacheAddressRuleTypes)
|
|
||||||
{
|
|
||||||
names.Add(GetEditorShowName(pair.Key, pair.Value));
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
public static List<string> GetPackRuleNames()
|
|
||||||
{
|
|
||||||
if (_setting == null)
|
|
||||||
LoadSettingData();
|
|
||||||
|
|
||||||
List<string> names = new List<string>();
|
|
||||||
foreach (var pair in _cachePackRuleTypes)
|
|
||||||
{
|
|
||||||
names.Add(GetEditorShowName(pair.Key, pair.Value));
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
public static List<string> GetFilterRuleNames()
|
|
||||||
{
|
|
||||||
if (_setting == null)
|
|
||||||
LoadSettingData();
|
|
||||||
|
|
||||||
List<string> names = new List<string>();
|
|
||||||
foreach (var pair in _cacheFilterRuleTypes)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
if (pair.Key == ruleName)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public static bool HasAddressRuleName(string ruleName)
|
|
||||||
{
|
|
||||||
foreach (var pair in _cacheAddressRuleTypes)
|
|
||||||
{
|
|
||||||
if (pair.Key == ruleName)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public static bool HasPackRuleName(string ruleName)
|
|
||||||
{
|
|
||||||
foreach (var pair in _cachePackRuleTypes)
|
|
||||||
{
|
|
||||||
if (pair.Key == ruleName)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public static bool HasFilterRuleName(string ruleName)
|
|
||||||
{
|
|
||||||
foreach (var pair in _cacheFilterRuleTypes)
|
|
||||||
{
|
|
||||||
if (pair.Key == ruleName)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载配置文件
|
/// 加载配置文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -194,6 +60,7 @@ namespace YooAsset.Editor
|
||||||
typeof(PackCollector),
|
typeof(PackCollector),
|
||||||
typeof(PackGroup),
|
typeof(PackGroup),
|
||||||
typeof(PackRawFile),
|
typeof(PackRawFile),
|
||||||
|
typeof(PackShaderVariants)
|
||||||
};
|
};
|
||||||
|
|
||||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IPackRule));
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IPackRule));
|
||||||
|
@ -314,7 +181,92 @@ namespace YooAsset.Editor
|
||||||
SaveFile();
|
SaveFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 实例类相关
|
public static List<RuleDisplayName> GetActiveRuleNames()
|
||||||
|
{
|
||||||
|
if (_setting == null)
|
||||||
|
LoadSettingData();
|
||||||
|
|
||||||
|
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||||
|
foreach (var pair in _cacheActiveRuleTypes)
|
||||||
|
{
|
||||||
|
RuleDisplayName ruleName = new RuleDisplayName();
|
||||||
|
ruleName.ClassName = pair.Key;
|
||||||
|
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||||
|
names.Add(ruleName);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
public static List<RuleDisplayName> GetAddressRuleNames()
|
||||||
|
{
|
||||||
|
if (_setting == null)
|
||||||
|
LoadSettingData();
|
||||||
|
|
||||||
|
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||||
|
foreach (var pair in _cacheAddressRuleTypes)
|
||||||
|
{
|
||||||
|
RuleDisplayName ruleName = new RuleDisplayName();
|
||||||
|
ruleName.ClassName = pair.Key;
|
||||||
|
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||||
|
names.Add(ruleName);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
public static List<RuleDisplayName> GetPackRuleNames()
|
||||||
|
{
|
||||||
|
if (_setting == null)
|
||||||
|
LoadSettingData();
|
||||||
|
|
||||||
|
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||||
|
foreach (var pair in _cachePackRuleTypes)
|
||||||
|
{
|
||||||
|
RuleDisplayName ruleName = new RuleDisplayName();
|
||||||
|
ruleName.ClassName = pair.Key;
|
||||||
|
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||||
|
names.Add(ruleName);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
public static List<RuleDisplayName> GetFilterRuleNames()
|
||||||
|
{
|
||||||
|
if (_setting == null)
|
||||||
|
LoadSettingData();
|
||||||
|
|
||||||
|
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||||
|
foreach (var pair in _cacheFilterRuleTypes)
|
||||||
|
{
|
||||||
|
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 = EditorAttribute.GetAttribute<DisplayNameAttribute>(type);
|
||||||
|
if (attribute != null && string.IsNullOrEmpty(attribute.DisplayName) == false)
|
||||||
|
return attribute.DisplayName;
|
||||||
|
else
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasActiveRuleName(string ruleName)
|
||||||
|
{
|
||||||
|
return _cacheActiveRuleTypes.Keys.Contains(ruleName);
|
||||||
|
}
|
||||||
|
public static bool HasAddressRuleName(string ruleName)
|
||||||
|
{
|
||||||
|
return _cacheAddressRuleTypes.Keys.Contains(ruleName);
|
||||||
|
}
|
||||||
|
public static bool HasPackRuleName(string ruleName)
|
||||||
|
{
|
||||||
|
return _cachePackRuleTypes.Keys.Contains(ruleName);
|
||||||
|
}
|
||||||
|
public static bool HasFilterRuleName(string ruleName)
|
||||||
|
{
|
||||||
|
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
|
||||||
|
}
|
||||||
|
|
||||||
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
||||||
{
|
{
|
||||||
if (_cacheActiveRuleInstance.TryGetValue(ruleName, out IActiveRule instance))
|
if (_cacheActiveRuleInstance.TryGetValue(ruleName, out IActiveRule instance))
|
||||||
|
@ -400,7 +352,6 @@ namespace YooAsset.Editor
|
||||||
Setting.UniqueBundleName = uniqueBundleName;
|
Setting.UniqueBundleName = uniqueBundleName;
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ModifyShowEditorAlias(bool showAlias)
|
public static void ModifyShowEditorAlias(bool showAlias)
|
||||||
{
|
{
|
||||||
Setting.ShowEditorAlias = showAlias;
|
Setting.ShowEditorAlias = showAlias;
|
||||||
|
|
|
@ -20,10 +20,10 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
private Button _saveButton;
|
private Button _saveButton;
|
||||||
private List<string> _collectorTypeList;
|
private List<string> _collectorTypeList;
|
||||||
private List<string> _activeRuleList;
|
private List<RuleDisplayName> _activeRuleList;
|
||||||
private List<string> _addressRuleList;
|
private List<RuleDisplayName> _addressRuleList;
|
||||||
private List<string> _packRuleList;
|
private List<RuleDisplayName> _packRuleList;
|
||||||
private List<string> _filterRuleList;
|
private List<RuleDisplayName> _filterRuleList;
|
||||||
|
|
||||||
private Toggle _showPackageToogle;
|
private Toggle _showPackageToogle;
|
||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
|
@ -43,7 +43,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
private VisualElement _collectorContainer;
|
private VisualElement _collectorContainer;
|
||||||
private ScrollView _collectorScrollView;
|
private ScrollView _collectorScrollView;
|
||||||
private PopupField<string> _activeRulePopupField;
|
private PopupField<RuleDisplayName> _activeRulePopupField;
|
||||||
|
|
||||||
private int _lastModifyPackageIndex = 0;
|
private int _lastModifyPackageIndex = 0;
|
||||||
private int _lastModifyGroupIndex = 0;
|
private int _lastModifyGroupIndex = 0;
|
||||||
|
@ -62,8 +62,10 @@ namespace YooAsset.Editor
|
||||||
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
||||||
$"{nameof(ECollectorType.DependAssetCollector)}"
|
$"{nameof(ECollectorType.DependAssetCollector)}"
|
||||||
};
|
};
|
||||||
|
_activeRuleList = AssetBundleCollectorSettingData.GetActiveRuleNames();
|
||||||
RefreshNames();
|
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
||||||
|
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
||||||
|
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
||||||
|
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
|
@ -98,7 +100,6 @@ namespace YooAsset.Editor
|
||||||
_showEditorAliasToggle.RegisterValueChangedCallback(evt =>
|
_showEditorAliasToggle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleCollectorSettingData.ModifyShowEditorAlias(evt.newValue);
|
AssetBundleCollectorSettingData.ModifyShowEditorAlias(evt.newValue);
|
||||||
RefreshNames();
|
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -243,21 +244,23 @@ namespace YooAsset.Editor
|
||||||
// 分组激活规则
|
// 分组激活规则
|
||||||
var activeRuleContainer = root.Q("ActiveRuleContainer");
|
var activeRuleContainer = root.Q("ActiveRuleContainer");
|
||||||
{
|
{
|
||||||
_activeRulePopupField = new PopupField<string>("Active Rule", _activeRuleList, 0);
|
_activeRulePopupField = new PopupField<RuleDisplayName>("Active Rule", _activeRuleList, 0);
|
||||||
_activeRulePopupField.name = "ActiveRuleMaskField";
|
_activeRulePopupField.name = "ActiveRuleMaskField";
|
||||||
_activeRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
_activeRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
activeRuleContainer.Add(_activeRulePopupField);
|
_activeRulePopupField.formatListItemCallback = FormatListItemCallback;
|
||||||
|
_activeRulePopupField.formatSelectedValueCallback = FormatSelectedValueCallback;
|
||||||
_activeRulePopupField.RegisterValueChangedCallback(evt =>
|
_activeRulePopupField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||||
if (selectPackage != null && selectGroup != null)
|
if (selectPackage != null && selectGroup != null)
|
||||||
{
|
{
|
||||||
selectGroup.ActiveRuleName = evt.newValue;
|
selectGroup.ActiveRuleName = evt.newValue.ClassName;
|
||||||
AssetBundleCollectorSettingData.ModifyGroup(selectPackage, selectGroup);
|
AssetBundleCollectorSettingData.ModifyGroup(selectPackage, selectGroup);
|
||||||
FillGroupViewData();
|
FillGroupViewData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
activeRuleContainer.Add(_activeRulePopupField);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新窗体
|
// 刷新窗体
|
||||||
|
@ -293,14 +296,6 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshNames()
|
|
||||||
{
|
|
||||||
_activeRuleList = AssetBundleCollectorSettingData.GetActiveRuleNames();
|
|
||||||
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
|
||||||
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
|
||||||
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RefreshWindow()
|
private void RefreshWindow()
|
||||||
{
|
{
|
||||||
_showPackageToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowPackageView);
|
_showPackageToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowPackageView);
|
||||||
|
@ -339,6 +334,20 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
AssetBundleCollectorSettingData.SaveFile();
|
AssetBundleCollectorSettingData.SaveFile();
|
||||||
}
|
}
|
||||||
|
private string FormatListItemCallback(RuleDisplayName ruleDisplayName)
|
||||||
|
{
|
||||||
|
if (_showEditorAliasToggle.value)
|
||||||
|
return ruleDisplayName.DisplayName;
|
||||||
|
else
|
||||||
|
return ruleDisplayName.ClassName;
|
||||||
|
}
|
||||||
|
private string FormatSelectedValueCallback(RuleDisplayName ruleDisplayName)
|
||||||
|
{
|
||||||
|
if (_showEditorAliasToggle.value)
|
||||||
|
return ruleDisplayName.DisplayName;
|
||||||
|
else
|
||||||
|
return ruleDisplayName.ClassName;
|
||||||
|
}
|
||||||
|
|
||||||
// 包裹列表相关
|
// 包裹列表相关
|
||||||
private void FillPackageViewData()
|
private void FillPackageViewData()
|
||||||
|
@ -428,7 +437,7 @@ namespace YooAsset.Editor
|
||||||
_groupListView.itemsSource = selectPackage.Groups;
|
_groupListView.itemsSource = selectPackage.Groups;
|
||||||
_groupListView.Rebuild();
|
_groupListView.Rebuild();
|
||||||
|
|
||||||
if(_lastModifyGroupIndex >=0 && _lastModifyGroupIndex < _groupListView.itemsSource.Count)
|
if (_lastModifyGroupIndex >= 0 && _lastModifyGroupIndex < _groupListView.itemsSource.Count)
|
||||||
{
|
{
|
||||||
_groupListView.selectedIndex = _lastModifyGroupIndex;
|
_groupListView.selectedIndex = _lastModifyGroupIndex;
|
||||||
}
|
}
|
||||||
|
@ -478,7 +487,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
_collectorContainer.visible = true;
|
_collectorContainer.visible = true;
|
||||||
_lastModifyGroupIndex = _groupListView.selectedIndex;
|
_lastModifyGroupIndex = _groupListView.selectedIndex;
|
||||||
_activeRulePopupField.SetValueWithoutNotify(selectGroup.ActiveRuleName);
|
_activeRulePopupField.SetValueWithoutNotify(GetActiveRuleIndex(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);
|
||||||
|
@ -582,21 +591,21 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
if (_enableAddressableToogle.value)
|
if (_enableAddressableToogle.value)
|
||||||
{
|
{
|
||||||
var popupField = new PopupField<string>(_addressRuleList, 0);
|
var popupField = new PopupField<RuleDisplayName>(_addressRuleList, 0);
|
||||||
popupField.name = "PopupField1";
|
popupField.name = "PopupField1";
|
||||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
popupField.style.width = 200;
|
popupField.style.width = 200;
|
||||||
elementBottom.Add(popupField);
|
elementBottom.Add(popupField);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
var popupField = new PopupField<string>(_packRuleList, 0);
|
var popupField = new PopupField<RuleDisplayName>(_packRuleList, 0);
|
||||||
popupField.name = "PopupField2";
|
popupField.name = "PopupField2";
|
||||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
popupField.style.width = 230;
|
popupField.style.width = 230;
|
||||||
elementBottom.Add(popupField);
|
elementBottom.Add(popupField);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
var popupField = new PopupField<string>(_filterRuleList, 0);
|
var popupField = new PopupField<RuleDisplayName>(_filterRuleList, 0);
|
||||||
popupField.name = "PopupField3";
|
popupField.name = "PopupField3";
|
||||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
popupField.style.width = 150;
|
popupField.style.width = 150;
|
||||||
|
@ -694,14 +703,15 @@ namespace YooAsset.Editor
|
||||||
});
|
});
|
||||||
|
|
||||||
// Address Rule
|
// Address Rule
|
||||||
var popupField1 = element.Q<PopupField<string>>("PopupField1");
|
var popupField1 = element.Q<PopupField<RuleDisplayName>>("PopupField1");
|
||||||
if (popupField1 != null)
|
if (popupField1 != null)
|
||||||
{
|
{
|
||||||
popupField1.index = GetAddressRuleIndex(collector.AddressRuleName);
|
popupField1.index = GetAddressRuleIndex(collector.AddressRuleName);
|
||||||
|
popupField1.formatListItemCallback = FormatListItemCallback;
|
||||||
|
popupField1.formatSelectedValueCallback = FormatSelectedValueCallback;
|
||||||
popupField1.RegisterValueChangedCallback(evt =>
|
popupField1.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
var target = (PopupField<string>)evt.target;
|
collector.AddressRuleName = evt.newValue.ClassName;
|
||||||
collector.AddressRuleName = AssetBundleCollectorSettingData.GetAddressRuleName(target.index);
|
|
||||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
if (foldout.value)
|
if (foldout.value)
|
||||||
{
|
{
|
||||||
|
@ -711,12 +721,13 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pack Rule
|
// Pack Rule
|
||||||
var popupField2 = element.Q<PopupField<string>>("PopupField2");
|
var popupField2 = element.Q<PopupField<RuleDisplayName>>("PopupField2");
|
||||||
popupField2.index = GetPackRuleIndex(collector.PackRuleName);
|
popupField2.index = GetPackRuleIndex(collector.PackRuleName);
|
||||||
|
popupField2.formatListItemCallback = FormatListItemCallback;
|
||||||
|
popupField2.formatSelectedValueCallback = FormatSelectedValueCallback;
|
||||||
popupField2.RegisterValueChangedCallback(evt =>
|
popupField2.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
var target = (PopupField<string>)evt.target;
|
collector.PackRuleName = evt.newValue.ClassName;
|
||||||
collector.PackRuleName = AssetBundleCollectorSettingData.GetPackRuleName(target.index);
|
|
||||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
if (foldout.value)
|
if (foldout.value)
|
||||||
{
|
{
|
||||||
|
@ -725,12 +736,13 @@ namespace YooAsset.Editor
|
||||||
});
|
});
|
||||||
|
|
||||||
// Filter Rule
|
// Filter Rule
|
||||||
var popupField3 = element.Q<PopupField<string>>("PopupField3");
|
var popupField3 = element.Q<PopupField<RuleDisplayName>>("PopupField3");
|
||||||
popupField3.index = GetFilterRuleIndex(collector.FilterRuleName);
|
popupField3.index = GetFilterRuleIndex(collector.FilterRuleName);
|
||||||
|
popupField3.formatListItemCallback = FormatListItemCallback;
|
||||||
|
popupField3.formatSelectedValueCallback = FormatSelectedValueCallback;
|
||||||
popupField3.RegisterValueChangedCallback(evt =>
|
popupField3.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
var target = (PopupField<string>)evt.target;
|
collector.FilterRuleName = evt.newValue.ClassName;
|
||||||
collector.FilterRuleName = AssetBundleCollectorSettingData.GetFilterRuleName(target.index);
|
|
||||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
if (foldout.value)
|
if (foldout.value)
|
||||||
{
|
{
|
||||||
|
@ -836,7 +848,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _addressRuleList.Count; i++)
|
for (int i = 0; i < _addressRuleList.Count; i++)
|
||||||
{
|
{
|
||||||
if (_addressRuleList[i] == ruleName)
|
if (_addressRuleList[i].ClassName == ruleName)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -845,7 +857,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _packRuleList.Count; i++)
|
for (int i = 0; i < _packRuleList.Count; i++)
|
||||||
{
|
{
|
||||||
if (_packRuleList[i] == ruleName)
|
if (_packRuleList[i].ClassName == ruleName)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -854,11 +866,20 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _filterRuleList.Count; i++)
|
for (int i = 0; i < _filterRuleList.Count; i++)
|
||||||
{
|
{
|
||||||
if (_filterRuleList[i] == ruleName)
|
if (_filterRuleList[i].ClassName == ruleName)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
private RuleDisplayName GetActiveRuleIndex(string ruleName)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _activeRuleList.Count; i++)
|
||||||
|
{
|
||||||
|
if (_activeRuleList[i].ClassName == ruleName)
|
||||||
|
return _activeRuleList[i];
|
||||||
|
}
|
||||||
|
return _activeRuleList[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -1,9 +1,7 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
[DisplayName("启用分组")]
|
||||||
/// 启用分组
|
|
||||||
/// </summary>
|
|
||||||
public class EnableGroup : IActiveRule
|
public class EnableGroup : IActiveRule
|
||||||
{
|
{
|
||||||
public bool IsActiveGroup()
|
public bool IsActiveGroup()
|
||||||
|
@ -12,9 +10,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
[DisplayName("禁用分组")]
|
||||||
/// 禁用分组
|
|
||||||
/// </summary>
|
|
||||||
public class DisableGroup : IActiveRule
|
public class DisableGroup : IActiveRule
|
||||||
{
|
{
|
||||||
public bool IsActiveGroup()
|
public bool IsActiveGroup()
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
[DisplayName("以文件名称为定位地址")]
|
||||||
/// 以文件名为定位地址
|
|
||||||
/// </summary>
|
|
||||||
[EditorShow("以文件名为定位地址")]
|
|
||||||
public class AddressByFileName : IAddressRule
|
public class AddressByFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
|
@ -14,10 +11,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
[DisplayName("以分组名称+文件名称为定位地址")]
|
||||||
/// 以组名+文件名为定位地址
|
|
||||||
/// </summary>
|
|
||||||
[EditorShow("以组名+文件名为定位地址")]
|
|
||||||
public class AddressByGroupAndFileName : IAddressRule
|
public class AddressByGroupAndFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
|
@ -27,10 +21,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
[DisplayName("以收集器名称+文件名称为定位地址")]
|
||||||
/// 以收集器名+文件名为定位地址
|
|
||||||
/// </summary>
|
|
||||||
[EditorShow("以收集器名+文件名为定位地址")]
|
|
||||||
public class AddressByCollectorAndFileName : IAddressRule
|
public class AddressByCollectorAndFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
|
|
|
@ -4,10 +4,7 @@ using System.IO;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
[DisplayName("收集所有资源")]
|
||||||
/// 收集所有资源
|
|
||||||
/// </summary>
|
|
||||||
[EditorShow("收集所有资源")]
|
|
||||||
public class CollectAll : IFilterRule
|
public class CollectAll : IFilterRule
|
||||||
{
|
{
|
||||||
public bool IsCollectAsset(FilterRuleData data)
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
|
@ -16,10 +13,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
[DisplayName("收集场景")]
|
||||||
/// 只收集场景
|
|
||||||
/// </summary>
|
|
||||||
[EditorShow("只收集场景")]
|
|
||||||
public class CollectScene : IFilterRule
|
public class CollectScene : IFilterRule
|
||||||
{
|
{
|
||||||
public bool IsCollectAsset(FilterRuleData data)
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
|
@ -28,10 +22,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
[DisplayName("收集预制体")]
|
||||||
/// 只收集预制体
|
|
||||||
/// </summary>
|
|
||||||
[EditorShow("只收集预制体")]
|
|
||||||
public class CollectPrefab : IFilterRule
|
public class CollectPrefab : IFilterRule
|
||||||
{
|
{
|
||||||
public bool IsCollectAsset(FilterRuleData data)
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
|
@ -40,16 +31,13 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
[DisplayName("收集精灵类型的纹理")]
|
||||||
/// 只收集精灵类型的资源
|
|
||||||
/// </summary>
|
|
||||||
[EditorShow("只收集精灵类型的资源")]
|
|
||||||
public class CollectSprite : IFilterRule
|
public class CollectSprite : IFilterRule
|
||||||
{
|
{
|
||||||
public bool IsCollectAsset(FilterRuleData data)
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
{
|
{
|
||||||
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
|
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
|
||||||
if(mainAssetType == typeof(Texture2D))
|
if (mainAssetType == typeof(Texture2D))
|
||||||
{
|
{
|
||||||
var texImporter = AssetImporter.GetAtPath(data.AssetPath) as TextureImporter;
|
var texImporter = AssetImporter.GetAtPath(data.AssetPath) as TextureImporter;
|
||||||
if (texImporter != null && texImporter.textureType == TextureImporterType.Sprite)
|
if (texImporter != null && texImporter.textureType == TextureImporterType.Sprite)
|
||||||
|
@ -64,10 +52,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
[DisplayName("收集着色器变种集合")]
|
||||||
/// 只收集着色器变种收集文件
|
|
||||||
/// </summary>
|
|
||||||
[EditorShow("只收集着色器变种收集文件")]
|
|
||||||
public class CollectShaderVariants : IFilterRule
|
public class CollectShaderVariants : IFilterRule
|
||||||
{
|
{
|
||||||
public bool IsCollectAsset(FilterRuleData data)
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
||||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image_backgroud.bundle"
|
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image_backgroud.bundle"
|
||||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view_main.bundle"
|
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view_main.bundle"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorShow("以文件路径作为资源包名")]
|
[DisplayName("以文件路径作为资源包名")]
|
||||||
public class PackSeparately : IPackRule
|
public class PackSeparately : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
string IPackRule.GetBundleName(PackRuleData data)
|
||||||
|
@ -26,7 +26,7 @@ namespace YooAsset.Editor
|
||||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image.bundle"
|
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image.bundle"
|
||||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view.bundle"
|
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view.bundle"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorShow("以父类文件夹路径作为资源包名")]
|
[DisplayName("以父类文件夹路径作为资源包名")]
|
||||||
public class PackDirectory : IPackRule
|
public class PackDirectory : IPackRule
|
||||||
{
|
{
|
||||||
public static PackDirectory StaticPackRule = new PackDirectory();
|
public static PackDirectory StaticPackRule = new PackDirectory();
|
||||||
|
@ -45,7 +45,7 @@ namespace YooAsset.Editor
|
||||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop.bundle"
|
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop.bundle"
|
||||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop.bundle"
|
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop.bundle"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorShow("以收集器路径下顶级文件夹为资源包名")]
|
[DisplayName("以收集器路径下顶级文件夹为资源包名")]
|
||||||
public class PackTopDirectory : IPackRule
|
public class PackTopDirectory : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
string IPackRule.GetBundleName(PackRuleData data)
|
||||||
|
@ -71,7 +71,7 @@ namespace YooAsset.Editor
|
||||||
/// 以收集器路径作为资源包名
|
/// 以收集器路径作为资源包名
|
||||||
/// 注意:收集的所有文件打进一个资源包
|
/// 注意:收集的所有文件打进一个资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorShow("以收集器路径作为资源包名")]
|
[DisplayName("以收集器路径作为资源包名")]
|
||||||
public class PackCollector : IPackRule
|
public class PackCollector : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
string IPackRule.GetBundleName(PackRuleData data)
|
||||||
|
@ -94,7 +94,7 @@ namespace YooAsset.Editor
|
||||||
/// 以分组名称作为资源包名
|
/// 以分组名称作为资源包名
|
||||||
/// 注意:收集的所有文件打进一个资源包
|
/// 注意:收集的所有文件打进一个资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorShow("以分组名称作为资源包名")]
|
[DisplayName("以分组名称作为资源包名")]
|
||||||
public class PackGroup : IPackRule
|
public class PackGroup : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
string IPackRule.GetBundleName(PackRuleData data)
|
||||||
|
@ -104,10 +104,10 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 原生文件打包模式
|
/// 打包原生文件
|
||||||
/// 注意:原生文件打包支持:图片,音频,视频,文本
|
/// 注意:原生文件打包支持:图片,音频,视频,文本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorShow("原生文件打包模式")]
|
[DisplayName("打包原生文件")]
|
||||||
public class PackRawFile : IPackRule
|
public class PackRawFile : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
string IPackRule.GetBundleName(PackRuleData data)
|
||||||
|
@ -132,9 +132,9 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 着色器变种收集文件
|
/// 打包着色器变种集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorShow("着色器变种收集文件")]
|
[DisplayName("打包着色器变种集合")]
|
||||||
public class PackShaderVariants : IPackRule
|
public class PackShaderVariants : IPackRule
|
||||||
{
|
{
|
||||||
public string GetBundleName(PackRuleData data)
|
public string GetBundleName(PackRuleData data)
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class RuleDisplayName
|
||||||
|
{
|
||||||
|
public string ClassName;
|
||||||
|
public string DisplayName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: df712711c3830af419b7ada8fee53dda
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器显示名字
|
||||||
|
/// </summary>
|
||||||
|
public class DisplayNameAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string DisplayName;
|
||||||
|
|
||||||
|
public DisplayNameAttribute(string name)
|
||||||
|
{
|
||||||
|
this.DisplayName = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class EditorAttribute
|
||||||
|
{
|
||||||
|
internal static T GetAttribute<T>(Type type) where T : Attribute
|
||||||
|
{
|
||||||
|
return (T)type.GetCustomAttribute(typeof(T), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static T GetAttribute<T>(MethodInfo methodInfo) where T : Attribute
|
||||||
|
{
|
||||||
|
return (T)methodInfo.GetCustomAttribute(typeof(T), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static T GetAttribute<T>(FieldInfo field) where T : Attribute
|
||||||
|
{
|
||||||
|
return (T)field.GetCustomAttribute(typeof(T), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,55 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue