feat : asset bundle collector config upgrade compatible

pull/255/head
hevinci 2024-03-12 11:12:13 +08:00
parent ef8229981e
commit 0a709f741a
4 changed files with 38 additions and 2 deletions

View File

@ -10,7 +10,7 @@ namespace YooAsset.Editor
{ {
public class AssetBundleCollectorConfig public class AssetBundleCollectorConfig
{ {
public const string ConfigVersion = "v2.0.0"; public const string ConfigVersion = "v2.1";
public const string XmlVersion = "Version"; public const string XmlVersion = "Version";
public const string XmlCommon = "Common"; public const string XmlCommon = "Common";
@ -258,6 +258,23 @@ namespace YooAsset.Editor
if (configVersion == ConfigVersion) if (configVersion == ConfigVersion)
return true; return true;
// v2.0.0 -> v2.1
if (configVersion == "v2.0.0")
{
// 读取包裹配置
var packageNodeList = root.GetElementsByTagName(XmlPackage);
foreach (var packageNode in packageNodeList)
{
XmlElement packageElement = packageNode as XmlElement;
if (packageElement.HasAttribute(XmlIgnoreRuleName) == false)
packageElement.SetAttribute(XmlIgnoreRuleName, nameof(NormalIgnoreRule));
}
// 更新版本
root.SetAttribute(XmlVersion, "v2.1");
return UpdateXmlConfig(xmlDoc);
}
return false; return false;
} }
} }

View File

@ -56,6 +56,16 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public void CheckConfigError() public void CheckConfigError()
{ {
if (string.IsNullOrEmpty(IgnoreRuleName))
{
throw new Exception($"{nameof(IgnoreRuleName)} is null or empty !");
}
else
{
if (AssetBundleCollectorSettingData.HasIgnoreRuleName(IgnoreRuleName) == false)
throw new Exception($"Invalid {nameof(IIgnoreRule)} class type : {IgnoreRuleName} in package : {PackageName}");
}
foreach (var group in Groups) foreach (var group in Groups)
{ {
group.CheckConfigError(); group.CheckConfigError();
@ -68,6 +78,14 @@ namespace YooAsset.Editor
public bool FixConfigError() public bool FixConfigError()
{ {
bool isFixed = false; bool isFixed = false;
if (string.IsNullOrEmpty(IgnoreRuleName))
{
Debug.LogWarning($"Set the {nameof(IgnoreRuleName)} to {nameof(NormalIgnoreRule)}");
IgnoreRuleName = nameof(NormalIgnoreRule);
isFixed = true;
}
foreach (var group in Groups) foreach (var group in Groups)
{ {
if (group.FixConfigError()) if (group.FixConfigError())
@ -75,6 +93,7 @@ namespace YooAsset.Editor
isFixed = true; isFixed = true;
} }
} }
return isFixed; return isFixed;
} }

View File

@ -191,6 +191,7 @@ namespace YooAsset.Editor
if (isFixed) if (isFixed)
{ {
IsDirty = true; IsDirty = true;
Debug.Log("Fix package config error done !");
} }
} }

View File

@ -21,7 +21,6 @@
<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="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" /> <ui:Toggle label="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" />
<ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" /> <ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" />
<ui:Toggle label="Ignore Default Type" name="IgnoreDefaultType" style="width: 196px; -unity-text-align: middle-left;" />
<ui:Toggle label="Auto Collect Shaders" name="AutoCollectShaders" value="true" style="width: 196px; -unity-text-align: middle-left;" /> <ui:Toggle label="Auto Collect Shaders" name="AutoCollectShaders" value="true" style="width: 196px; -unity-text-align: middle-left;" />
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>