diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
index b2477cb..efb9a8d 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
@@ -132,7 +132,7 @@ namespace YooAsset.Editor
///
/// 获取打包收集的资源文件
///
- public List GetAllCollectAssets(EBuildMode buildMode, AssetBundleCollectorGroup group)
+ public List GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable, AssetBundleCollectorGroup group)
{
// 注意:模拟构建模式下只收集主资源
if (buildMode == EBuildMode.SimulateBuild)
@@ -187,7 +187,7 @@ namespace YooAsset.Editor
}
// 检测可寻址地址是否重复
- if (AssetBundleCollectorSettingData.Setting.EnableAddressable)
+ if (enableAddressable)
{
HashSet adressTemper = new HashSet();
foreach (var collectInfoPair in result)
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs
index 4768305..60fb1b7 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs
@@ -10,14 +10,21 @@ namespace YooAsset.Editor
{
public class AssetBundleCollectorConfig
{
- public const string ConfigVersion = "1.0";
+ public const string ConfigVersion = "2.0";
public const string XmlVersion = "Version";
public const string XmlCommon = "Common";
public const string XmlEnableAddressable = "AutoAddressable";
+ public const string XmlShowPackageView = "ShowPackageView";
+
+ public const string XmlPackage = "Package";
+ public const string XmlPackageName = "PackageName";
+ public const string XmlPackageDesc = "PackageDesc";
+
public const string XmlGroup = "Group";
public const string XmlGroupName = "GroupName";
public const string XmlGroupDesc = "GroupDesc";
+
public const string XmlCollector = "Collector";
public const string XmlCollectPath = "CollectPath";
public const string XmlCollectorGUID = "CollectGUID";
@@ -39,85 +46,108 @@ namespace YooAsset.Editor
throw new Exception($"Only support xml : {filePath}");
// 加载配置文件
- XmlDocument xml = new XmlDocument();
- xml.Load(filePath);
- XmlElement root = xml.DocumentElement;
+ XmlDocument xmlDoc = new XmlDocument();
+ xmlDoc.Load(filePath);
+ XmlElement root = xmlDoc.DocumentElement;
// 读取配置版本
string configVersion = root.GetAttribute(XmlVersion);
if (configVersion != ConfigVersion)
{
- throw new Exception($"The config version is invalid : {configVersion}");
+ if (UpdateXmlConfig(xmlDoc) == false)
+ throw new Exception($"The config version update failed : {configVersion} -> {ConfigVersion}");
+ else
+ Debug.Log($"The config version update succeed : {configVersion} -> {ConfigVersion}");
}
// 读取公共配置
bool enableAddressable = false;
+ bool showPackageView = false;
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(XmlShowPackageView) == false)
+ throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}");
+
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
+ showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
}
- // 读取分组配置
- List groupTemper = new List();
- var groupNodeList = root.GetElementsByTagName(XmlGroup);
- foreach (var groupNode in groupNodeList)
+ // 读取包裹配置
+ List packages = new List();
+ var packageNodeList = root.GetElementsByTagName(XmlPackage);
+ foreach (var packageNode in packageNodeList)
{
- XmlElement groupElement = groupNode as XmlElement;
- if (groupElement.HasAttribute(XmlGroupName) == false)
- throw new Exception($"Not found attribute {XmlGroupName} in {XmlGroup}");
- if (groupElement.HasAttribute(XmlGroupDesc) == false)
- throw new Exception($"Not found attribute {XmlGroupDesc} in {XmlGroup}");
- if (groupElement.HasAttribute(XmlAssetTags) == false)
- throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGroup}");
+ XmlElement packageElement = packageNode as XmlElement;
+ if (packageElement.HasAttribute(XmlPackageName) == false)
+ throw new Exception($"Not found attribute {XmlPackageName} in {XmlPackage}");
+ if (packageElement.HasAttribute(XmlPackageDesc) == false)
+ throw new Exception($"Not found attribute {XmlPackageDesc} in {XmlPackage}");
- AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
- group.GroupName = groupElement.GetAttribute(XmlGroupName);
- group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc);
- group.AssetTags = groupElement.GetAttribute(XmlAssetTags);
- groupTemper.Add(group);
+ AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
+ package.PackageName = packageElement.GetAttribute(XmlPackageName);
+ package.PackageDesc = packageElement.GetAttribute(XmlPackageDesc);
+ packages.Add(package);
- // 读取收集器配置
- var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
- foreach (var collectorNode in collectorNodeList)
+ // 读取分组配置
+ var groupNodeList = packageElement.GetElementsByTagName(XmlGroup);
+ foreach (var groupNode in groupNodeList)
{
- XmlElement collectorElement = collectorNode as XmlElement;
- if (collectorElement.HasAttribute(XmlCollectPath) == false)
- throw new Exception($"Not found attribute {XmlCollectPath} in {XmlCollector}");
- if (collectorElement.HasAttribute(XmlCollectorType) == false)
- throw new Exception($"Not found attribute {XmlCollectorType} in {XmlCollector}");
- if (collectorElement.HasAttribute(XmlAddressRule) == false)
- throw new Exception($"Not found attribute {XmlAddressRule} in {XmlCollector}");
- if (collectorElement.HasAttribute(XmlPackRule) == false)
- throw new Exception($"Not found attribute {XmlPackRule} in {XmlCollector}");
- if (collectorElement.HasAttribute(XmlFilterRule) == false)
- throw new Exception($"Not found attribute {XmlFilterRule} in {XmlCollector}");
- if (collectorElement.HasAttribute(XmlAssetTags) == false)
- throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}");
+ XmlElement groupElement = groupNode as XmlElement;
+ if (groupElement.HasAttribute(XmlGroupName) == false)
+ throw new Exception($"Not found attribute {XmlGroupName} in {XmlGroup}");
+ if (groupElement.HasAttribute(XmlGroupDesc) == false)
+ throw new Exception($"Not found attribute {XmlGroupDesc} in {XmlGroup}");
+ if (groupElement.HasAttribute(XmlAssetTags) == false)
+ throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGroup}");
- string collectorGUID = string.Empty;
- if (collectorElement.HasAttribute(XmlCollectorGUID))
- collectorGUID = collectorElement.GetAttribute(XmlCollectorGUID);
+ AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
+ group.GroupName = groupElement.GetAttribute(XmlGroupName);
+ group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc);
+ group.AssetTags = groupElement.GetAttribute(XmlAssetTags);
+ package.Groups.Add(group);
- AssetBundleCollector collector = new AssetBundleCollector();
- collector.CollectPath = collectorElement.GetAttribute(XmlCollectPath);
- collector.CollectorGUID = collectorGUID;
- collector.CollectorType = StringUtility.NameToEnum(collectorElement.GetAttribute(XmlCollectorType));
- collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
- collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
- collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
- collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags);
- group.Collectors.Add(collector);
+ // 读取收集器配置
+ var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
+ foreach (var collectorNode in collectorNodeList)
+ {
+ XmlElement collectorElement = collectorNode as XmlElement;
+ if (collectorElement.HasAttribute(XmlCollectPath) == false)
+ throw new Exception($"Not found attribute {XmlCollectPath} in {XmlCollector}");
+ if (collectorElement.HasAttribute(XmlCollectorGUID) == false)
+ throw new Exception($"Not found attribute {XmlCollectorGUID} in {XmlCollector}");
+ if (collectorElement.HasAttribute(XmlCollectorType) == false)
+ throw new Exception($"Not found attribute {XmlCollectorType} in {XmlCollector}");
+ if (collectorElement.HasAttribute(XmlAddressRule) == false)
+ throw new Exception($"Not found attribute {XmlAddressRule} in {XmlCollector}");
+ if (collectorElement.HasAttribute(XmlPackRule) == false)
+ throw new Exception($"Not found attribute {XmlPackRule} in {XmlCollector}");
+ if (collectorElement.HasAttribute(XmlFilterRule) == false)
+ throw new Exception($"Not found attribute {XmlFilterRule} in {XmlCollector}");
+ if (collectorElement.HasAttribute(XmlAssetTags) == false)
+ throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}");
+
+ AssetBundleCollector collector = new AssetBundleCollector();
+ collector.CollectPath = collectorElement.GetAttribute(XmlCollectPath);
+ collector.CollectorGUID = collectorElement.GetAttribute(XmlCollectorGUID);
+ collector.CollectorType = StringUtility.NameToEnum(collectorElement.GetAttribute(XmlCollectorType));
+ collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
+ collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
+ collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
+ collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags);
+ group.Collectors.Add(collector);
+ }
}
}
// 保存配置数据
AssetBundleCollectorSettingData.ClearAll();
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
- AssetBundleCollectorSettingData.Setting.Groups.AddRange(groupTemper);
+ AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
+ AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
AssetBundleCollectorSettingData.SaveFile();
Debug.Log($"导入配置完毕!");
}
@@ -145,29 +175,39 @@ namespace YooAsset.Editor
// 设置公共配置
var commonElement = xmlDoc.CreateElement(XmlCommon);
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
+ commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
root.AppendChild(commonElement);
- // 设置分组配置
- foreach (var group in AssetBundleCollectorSettingData.Setting.Groups)
+ // 设置Package配置
+ foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
{
- var groupElement = xmlDoc.CreateElement(XmlGroup);
- groupElement.SetAttribute(XmlGroupName, group.GroupName);
- groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc);
- groupElement.SetAttribute(XmlAssetTags, group.AssetTags);
- root.AppendChild(groupElement);
+ var packageElement = xmlDoc.CreateElement(XmlPackage);
+ packageElement.SetAttribute(XmlPackageName, package.PackageName);
+ packageElement.SetAttribute(XmlPackageDesc, package.PackageDesc);
+ root.AppendChild(packageElement);
- // 设置收集器配置
- foreach (var collector in group.Collectors)
+ // 设置分组配置
+ foreach (var group in package.Groups)
{
- 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);
- collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
- collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
- groupElement.AppendChild(collectorElement);
+ var groupElement = xmlDoc.CreateElement(XmlGroup);
+ groupElement.SetAttribute(XmlGroupName, group.GroupName);
+ groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc);
+ groupElement.SetAttribute(XmlAssetTags, group.AssetTags);
+ packageElement.AppendChild(groupElement);
+
+ // 设置收集器配置
+ foreach (var collector in group.Collectors)
+ {
+ 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);
+ collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
+ collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
+ groupElement.AppendChild(collectorElement);
+ }
}
}
@@ -175,5 +215,65 @@ namespace YooAsset.Editor
xmlDoc.Save(savePath);
Debug.Log($"导出配置完毕!");
}
+
+ ///
+ /// 升级XML配置表
+ ///
+ private static bool UpdateXmlConfig(XmlDocument xmlDoc)
+ {
+ XmlElement root = xmlDoc.DocumentElement;
+ string configVersion = root.GetAttribute(XmlVersion);
+ if (configVersion == ConfigVersion)
+ return true;
+
+ // 1.0 -> 2.0
+ if (configVersion == "1.0")
+ {
+ // 添加公共元素属性
+ var commonNodeList = root.GetElementsByTagName(XmlCommon);
+ if (commonNodeList.Count > 0)
+ {
+ XmlElement commonElement = commonNodeList[0] as XmlElement;
+ if (commonElement.HasAttribute(XmlShowPackageView) == false)
+ commonElement.SetAttribute(XmlShowPackageView, "False");
+ }
+
+ // 添加包裹元素
+ var packageElement = xmlDoc.CreateElement(XmlPackage);
+ packageElement.SetAttribute(XmlPackageName, "Default Package");
+ packageElement.SetAttribute(XmlPackageDesc, string.Empty);
+ root.AppendChild(packageElement);
+
+ // 获取所有分组元素
+ var groupNodeList = root.GetElementsByTagName(XmlGroup);
+ List temper = new List(groupNodeList.Count);
+ foreach (var groupNode in groupNodeList)
+ {
+ XmlElement groupElement = groupNode as XmlElement;
+ var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
+ foreach (var collectorNode in collectorNodeList)
+ {
+ XmlElement collectorElement = collectorNode as XmlElement;
+ if (collectorElement.HasAttribute(XmlCollectorGUID) == false)
+ collectorElement.SetAttribute(XmlCollectorGUID, string.Empty);
+ }
+ temper.Add(groupElement);
+ }
+
+ // 将分组元素转移至包裹元素下
+ foreach (var groupElement in temper)
+ {
+ root.RemoveChild(groupElement);
+ packageElement.AppendChild(groupElement);
+ }
+
+ // 更新版本
+ root.SetAttribute(XmlVersion, "2.0");
+
+ return UpdateXmlConfig(xmlDoc);
+ }
+
+ return false;
+ }
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs
index 8e19d22..334a18b 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs
@@ -50,10 +50,26 @@ namespace YooAsset.Editor
}
}
+ ///
+ /// 修复配置错误
+ ///
+ public bool FixConfigError()
+ {
+ bool isFixed = false;
+ foreach (var collector in Collectors)
+ {
+ if (collector.FixConfigError())
+ {
+ isFixed = true;
+ }
+ }
+ return isFixed;
+ }
+
///
/// 获取打包收集的资源文件
///
- public List GetAllCollectAssets(EBuildMode buildMode)
+ public List GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
{
Dictionary result = new Dictionary(10000);
@@ -67,7 +83,7 @@ namespace YooAsset.Editor
// 收集打包资源
foreach (var collector in Collectors)
{
- var temper = collector.GetAllCollectAssets(buildMode, this);
+ var temper = collector.GetAllCollectAssets(buildMode, enableAddressable, this);
foreach (var assetInfo in temper)
{
if (result.ContainsKey(assetInfo.AssetPath) == false)
@@ -78,7 +94,7 @@ namespace YooAsset.Editor
}
// 检测可寻址地址是否重复
- if (AssetBundleCollectorSettingData.Setting.EnableAddressable)
+ if (enableAddressable)
{
HashSet adressTemper = new HashSet();
foreach (var collectInfoPair in result)
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs
new file mode 100644
index 0000000..453274d
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs
@@ -0,0 +1,125 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using UnityEditor;
+
+namespace YooAsset.Editor
+{
+ [Serializable]
+ public class AssetBundleCollectorPackage
+ {
+ ///
+ /// 包裹名称
+ ///
+ public string PackageName = string.Empty;
+
+ ///
+ /// 包裹描述
+ ///
+ public string PackageDesc = string.Empty;
+
+ ///
+ /// 分组列表
+ ///
+ public List Groups = new List();
+
+
+ ///
+ /// 检测配置错误
+ ///
+ public void CheckConfigError()
+ {
+ foreach (var group in Groups)
+ {
+ group.CheckConfigError();
+ }
+ }
+
+ ///
+ /// 修复配置错误
+ ///
+ public bool FixConfigError()
+ {
+ bool isFixed = false;
+ foreach (var group in Groups)
+ {
+ if (group.FixConfigError())
+ {
+ isFixed = true;
+ }
+ }
+ return isFixed;
+ }
+
+ ///
+ /// 获取打包收集的资源文件
+ ///
+ public List GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
+ {
+ Dictionary result = new Dictionary(10000);
+
+ // 收集打包资源
+ foreach (var group in Groups)
+ {
+ var temper = group.GetAllCollectAssets(buildMode, enableAddressable);
+ foreach (var assetInfo in temper)
+ {
+ if (result.ContainsKey(assetInfo.AssetPath) == false)
+ result.Add(assetInfo.AssetPath, assetInfo);
+ else
+ throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath}");
+ }
+ }
+
+ // 检测可寻址地址是否重复
+ if (enableAddressable)
+ {
+ HashSet adressTemper = new HashSet();
+ foreach (var collectInfoPair in result)
+ {
+ if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
+ {
+ string address = collectInfoPair.Value.Address;
+ if (adressTemper.Contains(address) == false)
+ adressTemper.Add(address);
+ else
+ throw new Exception($"The address is existed : {address}");
+ }
+ }
+ }
+
+ // 返回列表
+ return result.Values.ToList();
+ }
+
+ ///
+ /// 获取所有的资源标签
+ ///
+ public List GetAllTags()
+ {
+ HashSet result = new HashSet();
+ foreach (var group in Groups)
+ {
+ List groupTags = StringUtility.StringToStringList(group.AssetTags, ';');
+ foreach (var tag in groupTags)
+ {
+ if (result.Contains(tag) == false)
+ result.Add(tag);
+ }
+
+ foreach (var collector in group.Collectors)
+ {
+ List collectorTags = StringUtility.StringToStringList(collector.AssetTags, ';');
+ foreach (var tag in collectorTags)
+ {
+ if (result.Contains(tag) == false)
+ result.Add(tag);
+ }
+ }
+ }
+ return result.ToList();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs.meta b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs.meta
new file mode 100644
index 0000000..1bcdc1c
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 154d1124b6089254895b0f2b672394d5
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
index 0e558d0..b6cd158 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
@@ -8,25 +8,39 @@ namespace YooAsset.Editor
{
public class AssetBundleCollectorSetting : ScriptableObject
{
+ ///
+ /// 是否显示包裹视图
+ ///
+ public bool ShowPackageView = false;
+
///
/// 是否启用可寻址资源定位
///
public bool EnableAddressable = false;
///
- /// 分组列表
+ /// 包裹列表
///
- public List Groups = new List();
+ public List Packages = new List();
+ ///
+ /// 清空所有数据
+ ///
+ public void ClearAll()
+ {
+ EnableAddressable = false;
+ Packages.Clear();
+ }
+
///
/// 检测配置错误
///
public void CheckConfigError()
{
- foreach (var group in Groups)
+ foreach (var package in Packages)
{
- group.CheckConfigError();
+ package.CheckConfigError();
}
}
@@ -35,88 +49,64 @@ namespace YooAsset.Editor
///
public bool FixConfigError()
{
- bool result = false;
- foreach (var group in Groups)
+ bool isFixed = false;
+ foreach (var package in Packages)
{
- foreach (var collector in group.Collectors)
+ if (package.FixConfigError())
{
- bool isFixed = collector.FixConfigError();
- if (isFixed)
- {
- result = true;
- }
+ isFixed = true;
}
}
- return result;
+ return isFixed;
}
///
/// 获取所有的资源标签
///
- public List GetAllTags()
+ public List GetPackageAllTags(string packageName)
{
- HashSet result = new HashSet();
- foreach (var group in Groups)
+ foreach (var package in Packages)
{
- List groupTags = StringUtility.StringToStringList(group.AssetTags, ';');
- foreach (var tag in groupTags)
+ if (package.PackageName == packageName)
{
- if (result.Contains(tag) == false)
- result.Add(tag);
- }
-
- foreach (var collector in group.Collectors)
- {
- List collectorTags = StringUtility.StringToStringList(collector.AssetTags, ';');
- foreach (var tag in collectorTags)
- {
- if (result.Contains(tag) == false)
- result.Add(tag);
- }
+ return package.GetAllTags();
}
}
- return result.ToList();
+
+ Debug.LogWarning($"Not found package : {packageName}");
+ return new List();
+ }
+
+ ///
+ /// 获取包裹收集的资源文件
+ ///
+ public List GetPackageAssets(EBuildMode buildMode, string packageName)
+ {
+ if (string.IsNullOrEmpty(packageName))
+ throw new Exception("Build Package name is null or mepty !");
+
+ foreach (var package in Packages)
+ {
+ if (package.PackageName == packageName)
+ {
+ return package.GetAllCollectAssets(buildMode, EnableAddressable);
+ }
+ }
+ throw new Exception($"Not found collector pacakge : {packageName}");
}
///
- /// 获取打包收集的资源文件
+ /// 获取所有包裹收集的资源文件
///
- public List GetAllCollectAssets(EBuildMode buildMode)
+ public List GetAllPackageAssets(EBuildMode buildMode)
{
- Dictionary result = new Dictionary(10000);
-
- // 收集打包资源
- foreach (var group in Groups)
+ List result = new List(1000);
+ foreach (var package in Packages)
{
- var temper = group.GetAllCollectAssets(buildMode);
- foreach (var assetInfo in temper)
- {
- if (result.ContainsKey(assetInfo.AssetPath) == false)
- result.Add(assetInfo.AssetPath, assetInfo);
- else
- throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath}");
- }
+ var temper = package.GetAllCollectAssets(buildMode, EnableAddressable);
+ result.AddRange(temper);
}
-
- // 检测可寻址地址是否重复
- if (EnableAddressable)
- {
- HashSet adressTemper = new HashSet();
- foreach (var collectInfoPair in result)
- {
- if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
- {
- string address = collectInfoPair.Value.Address;
- if (adressTemper.Contains(address) == false)
- adressTemper.Add(address);
- else
- throw new Exception($"The address is existed : {address}");
- }
- }
- }
-
- // 返回列表
- return result.Values.ToList();
+ return result;
}
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs
index 45862bc..53d46c1 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs
@@ -256,14 +256,13 @@ namespace YooAsset.Editor
IsDirty = true;
}
}
-
+
///
/// 清空所有数据
///
public static void ClearAll()
{
- Setting.EnableAddressable = false;
- Setting.Groups.Clear();
+ Setting.ClearAll();
SaveFile();
}
@@ -337,24 +336,56 @@ namespace YooAsset.Editor
}
}
- // 可寻址编辑相关
+ // 公共参数编辑相关
+ public static void ModifyPackageView(bool showPackageView)
+ {
+ Setting.ShowPackageView = showPackageView;
+ IsDirty = true;
+ }
public static void ModifyAddressable(bool enableAddressable)
{
Setting.EnableAddressable = enableAddressable;
IsDirty = true;
}
+ // 资源包裹编辑相关
+ public static void CreatePackage(string packageName)
+ {
+ AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
+ package.PackageName = packageName;
+ Setting.Packages.Add(package);
+ IsDirty = true;
+ }
+ public static void RemovePackage(AssetBundleCollectorPackage package)
+ {
+ if (Setting.Packages.Remove(package))
+ {
+ IsDirty = true;
+ }
+ else
+ {
+ Debug.LogWarning($"Failed remove package : {package.PackageName}");
+ }
+ }
+ public static void ModifyPackage(AssetBundleCollectorPackage package)
+ {
+ if (package != null)
+ {
+ IsDirty = true;
+ }
+ }
+
// 资源分组编辑相关
- public static void CreateGroup(string groupName)
+ public static void CreateGroup(AssetBundleCollectorPackage package, string groupName)
{
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
group.GroupName = groupName;
- Setting.Groups.Add(group);
+ package.Groups.Add(group);
IsDirty = true;
}
- public static void RemoveGroup(AssetBundleCollectorGroup group)
+ public static void RemoveGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
{
- if (Setting.Groups.Remove(group))
+ if (package.Groups.Remove(group))
{
IsDirty = true;
}
@@ -363,18 +394,17 @@ namespace YooAsset.Editor
Debug.LogWarning($"Failed remove group : {group.GroupName}");
}
}
- public static void ModifyGroup(AssetBundleCollectorGroup group)
+ public static void ModifyGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
{
- if (group != null)
+ if (package != null && group != null)
{
IsDirty = true;
}
}
// 资源收集器编辑相关
- public static void CreateCollector(AssetBundleCollectorGroup group)
+ public static void CreateCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
{
- AssetBundleCollector collector = new AssetBundleCollector();
group.Collectors.Add(collector);
IsDirty = true;
}
@@ -400,9 +430,9 @@ namespace YooAsset.Editor
///
/// 获取所有的资源标签
///
- public static string GetAllTags()
+ public static string GetPackageAllTags(string packageName)
{
- var allTags = Setting.GetAllTags();
+ var allTags = Setting.GetPackageAllTags(packageName);
return string.Join(";", allTags);
}
}
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
index 0fe41e7..c512e70 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
@@ -24,15 +24,27 @@ namespace YooAsset.Editor
private List _addressRuleList;
private List _packRuleList;
private List _filterRuleList;
- private ListView _groupListView;
- private ScrollView _collectorScrollView;
- private PopupField _activeRulePopupField;
+
+ private Toggle _showPackageToogle;
private Toggle _enableAddressableToogle;
+
+ private VisualElement _packageContainer;
+ private ListView _packageListView;
+ private TextField _packageNameTxt;
+ private TextField _packageDescTxt;
+
+ private VisualElement _groupContainer;
+ private ListView _groupListView;
private TextField _groupNameTxt;
private TextField _groupDescTxt;
private TextField _groupAssetTagsTxt;
- private VisualElement _groupContainer;
- private string _lastModifyGroup = string.Empty;
+
+ private VisualElement _collectorContainer;
+ private ScrollView _collectorScrollView;
+ private PopupField _activeRulePopupField;
+
+ private int _lastModifyPackageIndex = 0;
+ private int _lastModifyGroupIndex = 0;
public void CreateGUI()
@@ -62,6 +74,20 @@ namespace YooAsset.Editor
visualAsset.CloneTree(root);
+ // 公共设置相关
+ _showPackageToogle = root.Q("ShowPackages");
+ _showPackageToogle.RegisterValueChangedCallback(evt =>
+ {
+ AssetBundleCollectorSettingData.ModifyPackageView(evt.newValue);
+ RefreshWindow();
+ });
+ _enableAddressableToogle = root.Q("EnableAddressable");
+ _enableAddressableToogle.RegisterValueChangedCallback(evt =>
+ {
+ AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
+ RefreshWindow();
+ });
+
// 配置修复按钮
var fixBtn = root.Q