parent
a89127df1d
commit
8cec0abf0e
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
|
@ -14,6 +15,11 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public string CollectPath = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 收集器的GUID
|
||||
/// </summary>
|
||||
public string CollectorGUID = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
|
@ -68,7 +74,8 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
if (AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(CollectPath) == null)
|
||||
string assetGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||
if (string.IsNullOrEmpty(assetGUID))
|
||||
throw new Exception($"Invalid collect path : {CollectPath}");
|
||||
|
||||
if (CollectorType == ECollectorType.None)
|
||||
|
@ -84,6 +91,44 @@ namespace YooAsset.Editor
|
|||
throw new Exception($"Invalid {nameof(IAddressRule)} class type : {AddressRuleName} in collector : {CollectPath}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复配置错误
|
||||
/// </summary>
|
||||
public bool FixConfigError()
|
||||
{
|
||||
bool isFixed = false;
|
||||
|
||||
if (string.IsNullOrEmpty(CollectorGUID) == false)
|
||||
{
|
||||
string convertAssetPath = AssetDatabase.GUIDToAssetPath(CollectorGUID);
|
||||
if (string.IsNullOrEmpty(convertAssetPath))
|
||||
{
|
||||
Debug.LogWarning($"Collector GUID {CollectorGUID} is invalid and has been auto removed !");
|
||||
CollectorGUID = string.Empty;
|
||||
isFixed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CollectPath != convertAssetPath)
|
||||
{
|
||||
CollectPath = convertAssetPath;
|
||||
isFixed = true;
|
||||
Debug.LogWarning($"Fix collect path : {CollectPath} -> {convertAssetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
string convertGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||
if(string.IsNullOrEmpty(convertGUID) == false)
|
||||
{
|
||||
CollectorGUID = convertGUID;
|
||||
}
|
||||
*/
|
||||
|
||||
return isFixed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
|
|
|
@ -20,12 +20,13 @@ namespace YooAsset.Editor
|
|||
public const string XmlGroupDesc = "GroupDesc";
|
||||
public const string XmlCollector = "Collector";
|
||||
public const string XmlCollectPath = "CollectPath";
|
||||
public const string XmlCollectorGUID = "CollectGUID";
|
||||
public const string XmlCollectorType = "CollectType";
|
||||
public const string XmlAddressRule = "AddressRule";
|
||||
public const string XmlPackRule = "PackRule";
|
||||
public const string XmlFilterRule = "FilterRule";
|
||||
public const string XmlAssetTags = "AssetTags";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导入XML配置表
|
||||
/// </summary>
|
||||
|
@ -44,7 +45,7 @@ namespace YooAsset.Editor
|
|||
|
||||
// 读取配置版本
|
||||
string configVersion = root.GetAttribute(XmlVersion);
|
||||
if(configVersion != ConfigVersion)
|
||||
if (configVersion != ConfigVersion)
|
||||
{
|
||||
throw new Exception($"The config version is invalid : {configVersion}");
|
||||
}
|
||||
|
@ -97,13 +98,18 @@ namespace YooAsset.Editor
|
|||
if (collectorElement.HasAttribute(XmlAssetTags) == false)
|
||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}");
|
||||
|
||||
string collectorGUID = string.Empty;
|
||||
if (collectorElement.HasAttribute(XmlCollectorGUID))
|
||||
collectorGUID = collectorElement.GetAttribute(XmlCollectorGUID);
|
||||
|
||||
AssetBundleCollector collector = new AssetBundleCollector();
|
||||
collector.CollectPath = collectorElement.GetAttribute(XmlCollectPath);
|
||||
collector.CollectorGUID = collectorGUID;
|
||||
collector.CollectorType = StringUtility.NameToEnum<ECollectorType>(collectorElement.GetAttribute(XmlCollectorType));
|
||||
collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
|
||||
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
||||
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
||||
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags); ;
|
||||
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags);
|
||||
group.Collectors.Add(collector);
|
||||
}
|
||||
}
|
||||
|
@ -155,6 +161,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
var collectorElement = xmlDoc.CreateElement(XmlCollector);
|
||||
collectorElement.SetAttribute(XmlCollectPath, collector.CollectPath);
|
||||
collectorElement.SetAttribute(XmlCollectorGUID, collector.CollectorGUID);
|
||||
collectorElement.SetAttribute(XmlCollectorType, collector.CollectorType.ToString());
|
||||
collectorElement.SetAttribute(XmlAddressRule, collector.AddressRuleName);
|
||||
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
||||
|
|
|
@ -30,6 +30,26 @@ namespace YooAsset.Editor
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复配置错误
|
||||
/// </summary>
|
||||
public bool FixConfigError()
|
||||
{
|
||||
bool result = false;
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
foreach (var collector in group.Collectors)
|
||||
{
|
||||
bool isFixed = collector.FixConfigError();
|
||||
if (isFixed)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的资源标签
|
||||
/// </summary>
|
||||
|
|
|
@ -232,7 +232,7 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储文件
|
||||
/// 存储配置文件
|
||||
/// </summary>
|
||||
public static void SaveFile()
|
||||
{
|
||||
|
@ -245,6 +245,18 @@ namespace YooAsset.Editor
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复配置文件
|
||||
/// </summary>
|
||||
public static void FixFile()
|
||||
{
|
||||
bool isFixed = Setting.FixConfigError();
|
||||
if (isFixed)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有数据
|
||||
/// </summary>
|
||||
|
@ -360,10 +372,9 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 资源收集器编辑相关
|
||||
public static void CreateCollector(AssetBundleCollectorGroup group, string collectPath)
|
||||
public static void CreateCollector(AssetBundleCollectorGroup group)
|
||||
{
|
||||
AssetBundleCollector collector = new AssetBundleCollector();
|
||||
collector.CollectPath = collectPath;
|
||||
group.Collectors.Add(collector);
|
||||
IsDirty = true;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,10 @@ namespace YooAsset.Editor
|
|||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 配置修复按钮
|
||||
var fixBtn = root.Q<Button>("FixButton");
|
||||
fixBtn.clicked += FixBtn_clicked;
|
||||
|
||||
// 导入导出按钮
|
||||
var exportBtn = root.Q<Button>("ExportButton");
|
||||
exportBtn.clicked += ExportBtn_clicked;
|
||||
|
@ -209,6 +213,10 @@ namespace YooAsset.Editor
|
|||
|
||||
FillGroupViewData();
|
||||
}
|
||||
private void FixBtn_clicked()
|
||||
{
|
||||
AssetBundleCollectorSettingData.FixFile();
|
||||
}
|
||||
private void ExportBtn_clicked()
|
||||
{
|
||||
string resultPath = EditorTools.OpenFolderPanel("Export XML", "Assets/");
|
||||
|
@ -472,6 +480,7 @@ namespace YooAsset.Editor
|
|||
objectField1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
collector.CollectorGUID = AssetDatabase.AssetPathToGUID(collector.CollectPath);
|
||||
objectField1.value.name = collector.CollectPath;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
|
@ -602,7 +611,7 @@ namespace YooAsset.Editor
|
|||
return;
|
||||
|
||||
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow AddCollector");
|
||||
AssetBundleCollectorSettingData.CreateCollector(selectGroup, string.Empty);
|
||||
AssetBundleCollectorSettingData.CreateCollector(selectGroup);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void RemoveCollectorBtn_clicked(AssetBundleCollector selectCollector)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="修复" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
</uie:Toolbar>
|
||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||
<ui:VisualElement name="LeftContainer" 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;">
|
||||
|
|
Loading…
Reference in New Issue