Update AssetBundleCollector
parent
e3dcaec9b5
commit
fe95b8ec5d
|
@ -214,13 +214,9 @@ namespace YooAsset.Editor
|
|||
}
|
||||
private bool IsCollectAsset(string assetPath)
|
||||
{
|
||||
// 如果收集全路径着色器
|
||||
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
||||
{
|
||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
return true;
|
||||
}
|
||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
return true;
|
||||
|
||||
// 根据规则设置过滤资源文件
|
||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||
|
@ -237,23 +233,16 @@ namespace YooAsset.Editor
|
|||
}
|
||||
private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
// 如果自动收集所有的着色器
|
||||
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
{
|
||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
{
|
||||
string bundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
||||
}
|
||||
return EditorTools.GetRegularPath(YooAssetSettings.UnityShadersBundleName).ToLower();
|
||||
}
|
||||
|
||||
// 根据规则设置获取资源包名称
|
||||
{
|
||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName));
|
||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
||||
}
|
||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName));
|
||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
||||
}
|
||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||
{
|
||||
|
|
|
@ -15,8 +15,6 @@ namespace YooAsset.Editor
|
|||
public const string XmlVersion = "Version";
|
||||
public const string XmlCommon = "Common";
|
||||
public const string XmlEnableAddressable = "AutoAddressable";
|
||||
public const string XmlAutoCollectShader = "AutoCollectShader";
|
||||
public const string XmlShaderBundleName = "ShaderBundleName";
|
||||
public const string XmlGroup = "Group";
|
||||
public const string XmlGroupName = "GroupName";
|
||||
public const string XmlGroupDesc = "GroupDesc";
|
||||
|
@ -53,22 +51,13 @@ namespace YooAsset.Editor
|
|||
|
||||
// 读取公共配置
|
||||
bool enableAddressable = false;
|
||||
bool autoCollectShaders = false;
|
||||
string shaderBundleName = string.Empty;
|
||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||
if (commonNodeList.Count > 0)
|
||||
{
|
||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
||||
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;
|
||||
autoCollectShaders = commonElement.GetAttribute(XmlAutoCollectShader) == "True" ? true : false;
|
||||
shaderBundleName = commonElement.GetAttribute(XmlShaderBundleName);
|
||||
}
|
||||
|
||||
// 读取分组配置
|
||||
|
@ -122,8 +111,6 @@ namespace YooAsset.Editor
|
|||
// 保存配置数据
|
||||
AssetBundleCollectorSettingData.ClearAll();
|
||||
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
||||
AssetBundleCollectorSettingData.Setting.AutoCollectShaders = autoCollectShaders;
|
||||
AssetBundleCollectorSettingData.Setting.ShadersBundleName = shaderBundleName;
|
||||
AssetBundleCollectorSettingData.Setting.Groups.AddRange(groupTemper);
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
Debug.Log($"导入配置完毕!");
|
||||
|
@ -152,8 +139,6 @@ namespace YooAsset.Editor
|
|||
// 设置公共配置
|
||||
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
||||
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
||||
commonElement.SetAttribute(XmlAutoCollectShader, AssetBundleCollectorSettingData.Setting.AutoCollectShaders.ToString());
|
||||
commonElement.SetAttribute(XmlShaderBundleName, AssetBundleCollectorSettingData.Setting.ShadersBundleName);
|
||||
root.AppendChild(commonElement);
|
||||
|
||||
// 设置分组配置
|
||||
|
|
|
@ -13,16 +13,6 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public bool EnableAddressable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 自动收集着色器
|
||||
/// </summary>
|
||||
public bool AutoCollectShaders = true;
|
||||
|
||||
/// <summary>
|
||||
/// 自动收集的着色器资源包名称
|
||||
/// </summary>
|
||||
public string ShadersBundleName = "myshaders";
|
||||
|
||||
/// <summary>
|
||||
/// 分组列表
|
||||
/// </summary>
|
||||
|
|
|
@ -250,8 +250,7 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public static void ClearAll()
|
||||
{
|
||||
Setting.AutoCollectShaders = false;
|
||||
Setting.ShadersBundleName = string.Empty;
|
||||
Setting.EnableAddressable = false;
|
||||
Setting.Groups.Clear();
|
||||
SaveFile();
|
||||
}
|
||||
|
@ -333,14 +332,6 @@ namespace YooAsset.Editor
|
|||
IsDirty = true;
|
||||
}
|
||||
|
||||
// 着色器编辑相关
|
||||
public static void ModifyShader(bool isCollectAllShaders, string shadersBundleName)
|
||||
{
|
||||
Setting.AutoCollectShaders = isCollectAllShaders;
|
||||
Setting.ShadersBundleName = shadersBundleName;
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
// 资源分组编辑相关
|
||||
public static void CreateGroup(string groupName)
|
||||
{
|
||||
|
|
|
@ -28,8 +28,6 @@ namespace YooAsset.Editor
|
|||
private ScrollView _collectorScrollView;
|
||||
private PopupField<string> _activeRulePopupField;
|
||||
private Toggle _enableAddressableToogle;
|
||||
private Toggle _autoCollectShaderToogle;
|
||||
private TextField _shaderBundleNameTxt;
|
||||
private TextField _groupNameTxt;
|
||||
private TextField _groupDescTxt;
|
||||
private TextField _groupAssetTagsTxt;
|
||||
|
@ -81,17 +79,6 @@ namespace YooAsset.Editor
|
|||
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
||||
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");
|
||||
|
@ -218,9 +205,6 @@ namespace YooAsset.Editor
|
|||
private void RefreshWindow()
|
||||
{
|
||||
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable);
|
||||
_autoCollectShaderToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.AutoCollectShaders);
|
||||
_shaderBundleNameTxt.SetEnabled(AssetBundleCollectorSettingData.Setting.AutoCollectShaders);
|
||||
_shaderBundleNameTxt.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShadersBundleName);
|
||||
_groupContainer.visible = false;
|
||||
|
||||
FillGroupViewData();
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
<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: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 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;" />
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 着色器变种收集文件
|
||||
/// </summary>
|
||||
public class PackShaderVariants : IPackRule
|
||||
{
|
||||
public string GetBundleName(PackRuleData data)
|
||||
{
|
||||
return YooAssetSettings.UnityShadersBundleName;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue