Update AssetBundleCollector
parent
e3dcaec9b5
commit
fe95b8ec5d
|
@ -213,14 +213,10 @@ namespace YooAsset.Editor
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private bool IsCollectAsset(string assetPath)
|
private bool IsCollectAsset(string assetPath)
|
||||||
{
|
|
||||||
// 如果收集全路径着色器
|
|
||||||
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
|
||||||
{
|
{
|
||||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (assetType == typeof(UnityEngine.Shader))
|
if (assetType == typeof(UnityEngine.Shader))
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// 根据规则设置过滤资源文件
|
// 根据规则设置过滤资源文件
|
||||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||||
|
@ -236,25 +232,18 @@ namespace YooAsset.Editor
|
||||||
return adressValue;
|
return adressValue;
|
||||||
}
|
}
|
||||||
private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
|
private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
|
||||||
// 如果自动收集所有的着色器
|
|
||||||
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
|
||||||
{
|
{
|
||||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (assetType == typeof(UnityEngine.Shader))
|
if (assetType == typeof(UnityEngine.Shader))
|
||||||
{
|
{
|
||||||
string bundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
return EditorTools.GetRegularPath(YooAssetSettings.UnityShadersBundleName).ToLower();
|
||||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据规则设置获取资源包名称
|
// 根据规则设置获取资源包名称
|
||||||
{
|
|
||||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName));
|
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName));
|
||||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
return EditorTools.GetRegularPath(bundleName).ToLower();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
List<string> tags = StringUtility.StringToStringList(group.AssetTags, ';');
|
List<string> tags = StringUtility.StringToStringList(group.AssetTags, ';');
|
||||||
|
|
|
@ -15,8 +15,6 @@ namespace YooAsset.Editor
|
||||||
public const string XmlVersion = "Version";
|
public const string XmlVersion = "Version";
|
||||||
public const string XmlCommon = "Common";
|
public const string XmlCommon = "Common";
|
||||||
public const string XmlEnableAddressable = "AutoAddressable";
|
public const string XmlEnableAddressable = "AutoAddressable";
|
||||||
public const string XmlAutoCollectShader = "AutoCollectShader";
|
|
||||||
public const string XmlShaderBundleName = "ShaderBundleName";
|
|
||||||
public const string XmlGroup = "Group";
|
public const string XmlGroup = "Group";
|
||||||
public const string XmlGroupName = "GroupName";
|
public const string XmlGroupName = "GroupName";
|
||||||
public const string XmlGroupDesc = "GroupDesc";
|
public const string XmlGroupDesc = "GroupDesc";
|
||||||
|
@ -53,22 +51,13 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 读取公共配置
|
// 读取公共配置
|
||||||
bool enableAddressable = false;
|
bool enableAddressable = false;
|
||||||
bool autoCollectShaders = false;
|
|
||||||
string shaderBundleName = string.Empty;
|
|
||||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||||
if (commonNodeList.Count > 0)
|
if (commonNodeList.Count > 0)
|
||||||
{
|
{
|
||||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||||
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
||||||
throw new Exception($"Not found attribute {XmlEnableAddressable} in {XmlCommon}");
|
throw new Exception($"Not found attribute {XmlEnableAddressable} in {XmlCommon}");
|
||||||
if (commonElement.HasAttribute(XmlAutoCollectShader) == false)
|
|
||||||
throw new Exception($"Not found attribute {XmlAutoCollectShader} in {XmlCommon}");
|
|
||||||
if (commonElement.HasAttribute(XmlShaderBundleName) == false)
|
|
||||||
throw new Exception($"Not found attribute {XmlShaderBundleName} in {XmlCommon}");
|
|
||||||
|
|
||||||
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||||
autoCollectShaders = commonElement.GetAttribute(XmlAutoCollectShader) == "True" ? true : false;
|
|
||||||
shaderBundleName = commonElement.GetAttribute(XmlShaderBundleName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取分组配置
|
// 读取分组配置
|
||||||
|
@ -122,8 +111,6 @@ namespace YooAsset.Editor
|
||||||
// 保存配置数据
|
// 保存配置数据
|
||||||
AssetBundleCollectorSettingData.ClearAll();
|
AssetBundleCollectorSettingData.ClearAll();
|
||||||
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
||||||
AssetBundleCollectorSettingData.Setting.AutoCollectShaders = autoCollectShaders;
|
|
||||||
AssetBundleCollectorSettingData.Setting.ShadersBundleName = shaderBundleName;
|
|
||||||
AssetBundleCollectorSettingData.Setting.Groups.AddRange(groupTemper);
|
AssetBundleCollectorSettingData.Setting.Groups.AddRange(groupTemper);
|
||||||
AssetBundleCollectorSettingData.SaveFile();
|
AssetBundleCollectorSettingData.SaveFile();
|
||||||
Debug.Log($"导入配置完毕!");
|
Debug.Log($"导入配置完毕!");
|
||||||
|
@ -152,8 +139,6 @@ namespace YooAsset.Editor
|
||||||
// 设置公共配置
|
// 设置公共配置
|
||||||
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
||||||
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
||||||
commonElement.SetAttribute(XmlAutoCollectShader, AssetBundleCollectorSettingData.Setting.AutoCollectShaders.ToString());
|
|
||||||
commonElement.SetAttribute(XmlShaderBundleName, AssetBundleCollectorSettingData.Setting.ShadersBundleName);
|
|
||||||
root.AppendChild(commonElement);
|
root.AppendChild(commonElement);
|
||||||
|
|
||||||
// 设置分组配置
|
// 设置分组配置
|
||||||
|
|
|
@ -13,16 +13,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable = false;
|
public bool EnableAddressable = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自动收集着色器
|
|
||||||
/// </summary>
|
|
||||||
public bool AutoCollectShaders = true;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自动收集的着色器资源包名称
|
|
||||||
/// </summary>
|
|
||||||
public string ShadersBundleName = "myshaders";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组列表
|
/// 分组列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -250,8 +250,7 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ClearAll()
|
public static void ClearAll()
|
||||||
{
|
{
|
||||||
Setting.AutoCollectShaders = false;
|
Setting.EnableAddressable = false;
|
||||||
Setting.ShadersBundleName = string.Empty;
|
|
||||||
Setting.Groups.Clear();
|
Setting.Groups.Clear();
|
||||||
SaveFile();
|
SaveFile();
|
||||||
}
|
}
|
||||||
|
@ -333,14 +332,6 @@ namespace YooAsset.Editor
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 着色器编辑相关
|
|
||||||
public static void ModifyShader(bool isCollectAllShaders, string shadersBundleName)
|
|
||||||
{
|
|
||||||
Setting.AutoCollectShaders = isCollectAllShaders;
|
|
||||||
Setting.ShadersBundleName = shadersBundleName;
|
|
||||||
IsDirty = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 资源分组编辑相关
|
// 资源分组编辑相关
|
||||||
public static void CreateGroup(string groupName)
|
public static void CreateGroup(string groupName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,8 +28,6 @@ namespace YooAsset.Editor
|
||||||
private ScrollView _collectorScrollView;
|
private ScrollView _collectorScrollView;
|
||||||
private PopupField<string> _activeRulePopupField;
|
private PopupField<string> _activeRulePopupField;
|
||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
private Toggle _autoCollectShaderToogle;
|
|
||||||
private TextField _shaderBundleNameTxt;
|
|
||||||
private TextField _groupNameTxt;
|
private TextField _groupNameTxt;
|
||||||
private TextField _groupDescTxt;
|
private TextField _groupDescTxt;
|
||||||
private TextField _groupAssetTagsTxt;
|
private TextField _groupAssetTagsTxt;
|
||||||
|
@ -81,17 +79,6 @@ namespace YooAsset.Editor
|
||||||
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
});
|
});
|
||||||
_autoCollectShaderToogle = root.Q<Toggle>("AutoCollectShader");
|
|
||||||
_autoCollectShaderToogle.RegisterValueChangedCallback(evt =>
|
|
||||||
{
|
|
||||||
AssetBundleCollectorSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value);
|
|
||||||
_shaderBundleNameTxt.SetEnabled(evt.newValue);
|
|
||||||
});
|
|
||||||
_shaderBundleNameTxt = root.Q<TextField>("ShaderBundleName");
|
|
||||||
_shaderBundleNameTxt.RegisterValueChangedCallback(evt =>
|
|
||||||
{
|
|
||||||
AssetBundleCollectorSettingData.ModifyShader(_autoCollectShaderToogle.value, evt.newValue);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 分组列表相关
|
// 分组列表相关
|
||||||
_groupListView = root.Q<ListView>("GroupListView");
|
_groupListView = root.Q<ListView>("GroupListView");
|
||||||
|
@ -218,9 +205,6 @@ namespace YooAsset.Editor
|
||||||
private void RefreshWindow()
|
private void RefreshWindow()
|
||||||
{
|
{
|
||||||
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable);
|
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable);
|
||||||
_autoCollectShaderToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.AutoCollectShaders);
|
|
||||||
_shaderBundleNameTxt.SetEnabled(AssetBundleCollectorSettingData.Setting.AutoCollectShaders);
|
|
||||||
_shaderBundleNameTxt.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShadersBundleName);
|
|
||||||
_groupContainer.visible = false;
|
_groupContainer.visible = false;
|
||||||
|
|
||||||
FillGroupViewData();
|
FillGroupViewData();
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
<ui:VisualElement name="RightContainer" style="flex-direction: column; flex-grow: 1;">
|
<ui:VisualElement name="RightContainer" style="flex-direction: column; flex-grow: 1;">
|
||||||
<ui:VisualElement name="PublicContainer" style="height: 30px; background-color: rgb(67, 67, 67); flex-direction: row; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
<ui:VisualElement name="PublicContainer" style="height: 30px; background-color: rgb(67, 67, 67); flex-direction: row; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
<ui:Toggle label="Enable Addressable" name="EnableAddressable" 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="Auto Collect Shaders" name="AutoCollectShader" style="width: 196px; -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:VisualElement name="ActiveRuleContainer" style="height: 20px;" />
|
||||||
|
|
|
@ -59,4 +59,15 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 只收集着色器变种收集文件
|
||||||
|
/// </summary>
|
||||||
|
public class CollectShaderVariants : IFilterRule
|
||||||
|
{
|
||||||
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
|
{
|
||||||
|
return Path.GetExtension(data.AssetPath) == ".shadervariants";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -113,4 +113,15 @@ namespace YooAsset.Editor
|
||||||
return StringUtility.RemoveExtension(data.AssetPath);
|
return StringUtility.RemoveExtension(data.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 着色器变种收集文件
|
||||||
|
/// </summary>
|
||||||
|
public class PackShaderVariants : IPackRule
|
||||||
|
{
|
||||||
|
public string GetBundleName(PackRuleData data)
|
||||||
|
{
|
||||||
|
return YooAssetSettings.UnityShadersBundleName;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue