Update AssetBundleCollector

编辑器支持分布式构建
pull/40/head
hevinci 2022-09-27 10:38:35 +08:00
parent 39c277b090
commit f0ac319a73
10 changed files with 658 additions and 210 deletions

View File

@ -132,7 +132,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取打包收集的资源文件 /// 获取打包收集的资源文件
/// </summary> /// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, AssetBundleCollectorGroup group) public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable, AssetBundleCollectorGroup group)
{ {
// 注意:模拟构建模式下只收集主资源 // 注意:模拟构建模式下只收集主资源
if (buildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.SimulateBuild)
@ -187,7 +187,7 @@ namespace YooAsset.Editor
} }
// 检测可寻址地址是否重复 // 检测可寻址地址是否重复
if (AssetBundleCollectorSettingData.Setting.EnableAddressable) if (enableAddressable)
{ {
HashSet<string> adressTemper = new HashSet<string>(); HashSet<string> adressTemper = new HashSet<string>();
foreach (var collectInfoPair in result) foreach (var collectInfoPair in result)

View File

@ -10,14 +10,21 @@ namespace YooAsset.Editor
{ {
public class AssetBundleCollectorConfig public class AssetBundleCollectorConfig
{ {
public const string ConfigVersion = "1.0"; public const string ConfigVersion = "2.0";
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 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 XmlGroup = "Group";
public const string XmlGroupName = "GroupName"; public const string XmlGroupName = "GroupName";
public const string XmlGroupDesc = "GroupDesc"; public const string XmlGroupDesc = "GroupDesc";
public const string XmlCollector = "Collector"; public const string XmlCollector = "Collector";
public const string XmlCollectPath = "CollectPath"; public const string XmlCollectPath = "CollectPath";
public const string XmlCollectorGUID = "CollectGUID"; public const string XmlCollectorGUID = "CollectGUID";
@ -39,31 +46,54 @@ namespace YooAsset.Editor
throw new Exception($"Only support xml : {filePath}"); throw new Exception($"Only support xml : {filePath}");
// 加载配置文件 // 加载配置文件
XmlDocument xml = new XmlDocument(); XmlDocument xmlDoc = new XmlDocument();
xml.Load(filePath); xmlDoc.Load(filePath);
XmlElement root = xml.DocumentElement; XmlElement root = xmlDoc.DocumentElement;
// 读取配置版本 // 读取配置版本
string configVersion = root.GetAttribute(XmlVersion); string configVersion = root.GetAttribute(XmlVersion);
if (configVersion != ConfigVersion) 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 enableAddressable = false;
bool showPackageView = false;
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(XmlShowPackageView) == false)
throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}");
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false; enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
} }
// 读取包裹配置
List<AssetBundleCollectorPackage> packages = new List<AssetBundleCollectorPackage>();
var packageNodeList = root.GetElementsByTagName(XmlPackage);
foreach (var packageNode in packageNodeList)
{
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}");
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
package.PackageName = packageElement.GetAttribute(XmlPackageName);
package.PackageDesc = packageElement.GetAttribute(XmlPackageDesc);
packages.Add(package);
// 读取分组配置 // 读取分组配置
List<AssetBundleCollectorGroup> groupTemper = new List<AssetBundleCollectorGroup>(); var groupNodeList = packageElement.GetElementsByTagName(XmlGroup);
var groupNodeList = root.GetElementsByTagName(XmlGroup);
foreach (var groupNode in groupNodeList) foreach (var groupNode in groupNodeList)
{ {
XmlElement groupElement = groupNode as XmlElement; XmlElement groupElement = groupNode as XmlElement;
@ -78,7 +108,7 @@ namespace YooAsset.Editor
group.GroupName = groupElement.GetAttribute(XmlGroupName); group.GroupName = groupElement.GetAttribute(XmlGroupName);
group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc); group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc);
group.AssetTags = groupElement.GetAttribute(XmlAssetTags); group.AssetTags = groupElement.GetAttribute(XmlAssetTags);
groupTemper.Add(group); package.Groups.Add(group);
// 读取收集器配置 // 读取收集器配置
var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector); var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
@ -87,6 +117,8 @@ namespace YooAsset.Editor
XmlElement collectorElement = collectorNode as XmlElement; XmlElement collectorElement = collectorNode as XmlElement;
if (collectorElement.HasAttribute(XmlCollectPath) == false) if (collectorElement.HasAttribute(XmlCollectPath) == false)
throw new Exception($"Not found attribute {XmlCollectPath} in {XmlCollector}"); 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) if (collectorElement.HasAttribute(XmlCollectorType) == false)
throw new Exception($"Not found attribute {XmlCollectorType} in {XmlCollector}"); throw new Exception($"Not found attribute {XmlCollectorType} in {XmlCollector}");
if (collectorElement.HasAttribute(XmlAddressRule) == false) if (collectorElement.HasAttribute(XmlAddressRule) == false)
@ -98,13 +130,9 @@ namespace YooAsset.Editor
if (collectorElement.HasAttribute(XmlAssetTags) == false) if (collectorElement.HasAttribute(XmlAssetTags) == false)
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}"); 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(); AssetBundleCollector collector = new AssetBundleCollector();
collector.CollectPath = collectorElement.GetAttribute(XmlCollectPath); collector.CollectPath = collectorElement.GetAttribute(XmlCollectPath);
collector.CollectorGUID = collectorGUID; collector.CollectorGUID = collectorElement.GetAttribute(XmlCollectorGUID);
collector.CollectorType = StringUtility.NameToEnum<ECollectorType>(collectorElement.GetAttribute(XmlCollectorType)); collector.CollectorType = StringUtility.NameToEnum<ECollectorType>(collectorElement.GetAttribute(XmlCollectorType));
collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule); collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule); collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
@ -113,11 +141,13 @@ namespace YooAsset.Editor
group.Collectors.Add(collector); group.Collectors.Add(collector);
} }
} }
}
// 保存配置数据 // 保存配置数据
AssetBundleCollectorSettingData.ClearAll(); AssetBundleCollectorSettingData.ClearAll();
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable; AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
AssetBundleCollectorSettingData.Setting.Groups.AddRange(groupTemper); AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
AssetBundleCollectorSettingData.SaveFile(); AssetBundleCollectorSettingData.SaveFile();
Debug.Log($"导入配置完毕!"); Debug.Log($"导入配置完毕!");
} }
@ -145,16 +175,25 @@ 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(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
root.AppendChild(commonElement); root.AppendChild(commonElement);
// 设置Package配置
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
{
var packageElement = xmlDoc.CreateElement(XmlPackage);
packageElement.SetAttribute(XmlPackageName, package.PackageName);
packageElement.SetAttribute(XmlPackageDesc, package.PackageDesc);
root.AppendChild(packageElement);
// 设置分组配置 // 设置分组配置
foreach (var group in AssetBundleCollectorSettingData.Setting.Groups) foreach (var group in package.Groups)
{ {
var groupElement = xmlDoc.CreateElement(XmlGroup); var groupElement = xmlDoc.CreateElement(XmlGroup);
groupElement.SetAttribute(XmlGroupName, group.GroupName); groupElement.SetAttribute(XmlGroupName, group.GroupName);
groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc); groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc);
groupElement.SetAttribute(XmlAssetTags, group.AssetTags); groupElement.SetAttribute(XmlAssetTags, group.AssetTags);
root.AppendChild(groupElement); packageElement.AppendChild(groupElement);
// 设置收集器配置 // 设置收集器配置
foreach (var collector in group.Collectors) foreach (var collector in group.Collectors)
@ -170,10 +209,71 @@ namespace YooAsset.Editor
groupElement.AppendChild(collectorElement); groupElement.AppendChild(collectorElement);
} }
} }
}
// 生成配置文件 // 生成配置文件
xmlDoc.Save(savePath); xmlDoc.Save(savePath);
Debug.Log($"导出配置完毕!"); Debug.Log($"导出配置完毕!");
} }
/// <summary>
/// 升级XML配置表
/// </summary>
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<XmlElement> temper = new List<XmlElement>(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;
}
} }
} }

View File

@ -50,10 +50,26 @@ namespace YooAsset.Editor
} }
} }
/// <summary>
/// 修复配置错误
/// </summary>
public bool FixConfigError()
{
bool isFixed = false;
foreach (var collector in Collectors)
{
if (collector.FixConfigError())
{
isFixed = true;
}
}
return isFixed;
}
/// <summary> /// <summary>
/// 获取打包收集的资源文件 /// 获取打包收集的资源文件
/// </summary> /// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode) public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
{ {
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000); Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
@ -67,7 +83,7 @@ namespace YooAsset.Editor
// 收集打包资源 // 收集打包资源
foreach (var collector in Collectors) foreach (var collector in Collectors)
{ {
var temper = collector.GetAllCollectAssets(buildMode, this); var temper = collector.GetAllCollectAssets(buildMode, enableAddressable, this);
foreach (var assetInfo in temper) foreach (var assetInfo in temper)
{ {
if (result.ContainsKey(assetInfo.AssetPath) == false) if (result.ContainsKey(assetInfo.AssetPath) == false)
@ -78,7 +94,7 @@ namespace YooAsset.Editor
} }
// 检测可寻址地址是否重复 // 检测可寻址地址是否重复
if (AssetBundleCollectorSettingData.Setting.EnableAddressable) if (enableAddressable)
{ {
HashSet<string> adressTemper = new HashSet<string>(); HashSet<string> adressTemper = new HashSet<string>();
foreach (var collectInfoPair in result) foreach (var collectInfoPair in result)

View File

@ -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
{
/// <summary>
/// 包裹名称
/// </summary>
public string PackageName = string.Empty;
/// <summary>
/// 包裹描述
/// </summary>
public string PackageDesc = string.Empty;
/// <summary>
/// 分组列表
/// </summary>
public List<AssetBundleCollectorGroup> Groups = new List<AssetBundleCollectorGroup>();
/// <summary>
/// 检测配置错误
/// </summary>
public void CheckConfigError()
{
foreach (var group in Groups)
{
group.CheckConfigError();
}
}
/// <summary>
/// 修复配置错误
/// </summary>
public bool FixConfigError()
{
bool isFixed = false;
foreach (var group in Groups)
{
if (group.FixConfigError())
{
isFixed = true;
}
}
return isFixed;
}
/// <summary>
/// 获取打包收集的资源文件
/// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
{
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(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<string> adressTemper = new HashSet<string>();
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();
}
/// <summary>
/// 获取所有的资源标签
/// </summary>
public List<string> GetAllTags()
{
HashSet<string> result = new HashSet<string>();
foreach (var group in Groups)
{
List<string> 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<string> collectorTags = StringUtility.StringToStringList(collector.AssetTags, ';');
foreach (var tag in collectorTags)
{
if (result.Contains(tag) == false)
result.Add(tag);
}
}
}
return result.ToList();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 154d1124b6089254895b0f2b672394d5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -8,25 +8,39 @@ namespace YooAsset.Editor
{ {
public class AssetBundleCollectorSetting : ScriptableObject public class AssetBundleCollectorSetting : ScriptableObject
{ {
/// <summary>
/// 是否显示包裹视图
/// </summary>
public bool ShowPackageView = false;
/// <summary> /// <summary>
/// 是否启用可寻址资源定位 /// 是否启用可寻址资源定位
/// </summary> /// </summary>
public bool EnableAddressable = false; public bool EnableAddressable = false;
/// <summary> /// <summary>
/// 分组列表 /// 包裹列表
/// </summary> /// </summary>
public List<AssetBundleCollectorGroup> Groups = new List<AssetBundleCollectorGroup>(); public List<AssetBundleCollectorPackage> Packages = new List<AssetBundleCollectorPackage>();
/// <summary>
/// 清空所有数据
/// </summary>
public void ClearAll()
{
EnableAddressable = false;
Packages.Clear();
}
/// <summary> /// <summary>
/// 检测配置错误 /// 检测配置错误
/// </summary> /// </summary>
public void CheckConfigError() public void CheckConfigError()
{ {
foreach (var group in Groups) foreach (var package in Packages)
{ {
group.CheckConfigError(); package.CheckConfigError();
} }
} }
@ -35,88 +49,64 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public bool FixConfigError() public bool FixConfigError()
{ {
bool result = false; bool isFixed = false;
foreach (var group in Groups) foreach (var package in Packages)
{ {
foreach (var collector in group.Collectors) if (package.FixConfigError())
{ {
bool isFixed = collector.FixConfigError(); isFixed = true;
if (isFixed)
{
result = true;
} }
} }
} return isFixed;
return result;
} }
/// <summary> /// <summary>
/// 获取所有的资源标签 /// 获取所有的资源标签
/// </summary> /// </summary>
public List<string> GetAllTags() public List<string> GetPackageAllTags(string packageName)
{ {
HashSet<string> result = new HashSet<string>(); foreach (var package in Packages)
foreach (var group in Groups)
{ {
List<string> groupTags = StringUtility.StringToStringList(group.AssetTags, ';'); if (package.PackageName == packageName)
foreach (var tag in groupTags)
{ {
if (result.Contains(tag) == false) return package.GetAllTags();
result.Add(tag); }
} }
foreach (var collector in group.Collectors) Debug.LogWarning($"Not found package : {packageName}");
{ return new List<string>();
List<string> collectorTags = StringUtility.StringToStringList(collector.AssetTags, ';');
foreach (var tag in collectorTags)
{
if (result.Contains(tag) == false)
result.Add(tag);
}
}
}
return result.ToList();
} }
/// <summary> /// <summary>
/// 获取包收集的资源文件 /// 获取包裹收集的资源文件
/// </summary> /// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode) public List<CollectAssetInfo> GetPackageAssets(EBuildMode buildMode, string packageName)
{ {
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000); if (string.IsNullOrEmpty(packageName))
throw new Exception("Build Package name is null or mepty !");
// 收集打包资源 foreach (var package in Packages)
foreach (var group in Groups)
{ {
var temper = group.GetAllCollectAssets(buildMode); if (package.PackageName == packageName)
foreach (var assetInfo in temper)
{ {
if (result.ContainsKey(assetInfo.AssetPath) == false) return package.GetAllCollectAssets(buildMode, EnableAddressable);
result.Add(assetInfo.AssetPath, assetInfo);
else
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath}");
} }
} }
throw new Exception($"Not found collector pacakge : {packageName}");
}
// 检测可寻址地址是否重复 /// <summary>
if (EnableAddressable) /// 获取所有包裹收集的资源文件
/// </summary>
public List<CollectAssetInfo> GetAllPackageAssets(EBuildMode buildMode)
{ {
HashSet<string> adressTemper = new HashSet<string>(); List<CollectAssetInfo> result = new List<CollectAssetInfo>(1000);
foreach (var collectInfoPair in result) foreach (var package in Packages)
{ {
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector) var temper = package.GetAllCollectAssets(buildMode, EnableAddressable);
{ result.AddRange(temper);
string address = collectInfoPair.Value.Address; }
if (adressTemper.Contains(address) == false) return result;
adressTemper.Add(address);
else
throw new Exception($"The address is existed : {address}");
}
}
}
// 返回列表
return result.Values.ToList();
} }
} }
} }

View File

@ -262,8 +262,7 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public static void ClearAll() public static void ClearAll()
{ {
Setting.EnableAddressable = false; Setting.ClearAll();
Setting.Groups.Clear();
SaveFile(); 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) public static void ModifyAddressable(bool enableAddressable)
{ {
Setting.EnableAddressable = enableAddressable; Setting.EnableAddressable = enableAddressable;
IsDirty = true; 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(); AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
group.GroupName = groupName; group.GroupName = groupName;
Setting.Groups.Add(group); package.Groups.Add(group);
IsDirty = true; 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; IsDirty = true;
} }
@ -363,18 +394,17 @@ namespace YooAsset.Editor
Debug.LogWarning($"Failed remove group : {group.GroupName}"); 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; IsDirty = true;
} }
} }
// 资源收集器编辑相关 // 资源收集器编辑相关
public static void CreateCollector(AssetBundleCollectorGroup group) public static void CreateCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
{ {
AssetBundleCollector collector = new AssetBundleCollector();
group.Collectors.Add(collector); group.Collectors.Add(collector);
IsDirty = true; IsDirty = true;
} }
@ -400,9 +430,9 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取所有的资源标签 /// 获取所有的资源标签
/// </summary> /// </summary>
public static string GetAllTags() public static string GetPackageAllTags(string packageName)
{ {
var allTags = Setting.GetAllTags(); var allTags = Setting.GetPackageAllTags(packageName);
return string.Join(";", allTags); return string.Join(";", allTags);
} }
} }

View File

@ -24,15 +24,27 @@ namespace YooAsset.Editor
private List<string> _addressRuleList; private List<string> _addressRuleList;
private List<string> _packRuleList; private List<string> _packRuleList;
private List<string> _filterRuleList; private List<string> _filterRuleList;
private ListView _groupListView;
private ScrollView _collectorScrollView; private Toggle _showPackageToogle;
private PopupField<string> _activeRulePopupField;
private Toggle _enableAddressableToogle; 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 _groupNameTxt;
private TextField _groupDescTxt; private TextField _groupDescTxt;
private TextField _groupAssetTagsTxt; private TextField _groupAssetTagsTxt;
private VisualElement _groupContainer;
private string _lastModifyGroup = string.Empty; private VisualElement _collectorContainer;
private ScrollView _collectorScrollView;
private PopupField<string> _activeRulePopupField;
private int _lastModifyPackageIndex = 0;
private int _lastModifyGroupIndex = 0;
public void CreateGUI() public void CreateGUI()
@ -62,6 +74,20 @@ namespace YooAsset.Editor
visualAsset.CloneTree(root); visualAsset.CloneTree(root);
// 公共设置相关
_showPackageToogle = root.Q<Toggle>("ShowPackages");
_showPackageToogle.RegisterValueChangedCallback(evt =>
{
AssetBundleCollectorSettingData.ModifyPackageView(evt.newValue);
RefreshWindow();
});
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable");
_enableAddressableToogle.RegisterValueChangedCallback(evt =>
{
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
RefreshWindow();
});
// 配置修复按钮 // 配置修复按钮
var fixBtn = root.Q<Button>("FixButton"); var fixBtn = root.Q<Button>("FixButton");
fixBtn.clicked += FixBtn_clicked; fixBtn.clicked += FixBtn_clicked;
@ -76,12 +102,50 @@ namespace YooAsset.Editor
_saveButton = root.Q<Button>("SaveButton"); _saveButton = root.Q<Button>("SaveButton");
_saveButton.clicked += SaveBtn_clicked; _saveButton.clicked += SaveBtn_clicked;
// 公共设置相关 // 包裹容器
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable"); _packageContainer = root.Q("PackageContainer");
_enableAddressableToogle.RegisterValueChangedCallback(evt =>
// 包裹列表相关
_packageListView = root.Q<ListView>("PackageListView");
_packageListView.makeItem = MakePackageListViewItem;
_packageListView.bindItem = BindPackageListViewItem;
#if UNITY_2020_1_OR_NEWER
_packageListView.onSelectionChange += PackageListView_onSelectionChange;
#else
_packageListView.onSelectionChanged += PackageListView_onSelectionChange;
#endif
// 包裹添加删除按钮
var packageAddContainer = root.Q("PackageAddContainer");
{ {
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue); var addBtn = packageAddContainer.Q<Button>("AddBtn");
RefreshWindow(); addBtn.clicked += AddPackageBtn_clicked;
var removeBtn = packageAddContainer.Q<Button>("RemoveBtn");
removeBtn.clicked += RemovePackageBtn_clicked;
}
// 包裹名称
_packageNameTxt = root.Q<TextField>("PackageName");
_packageNameTxt.RegisterValueChangedCallback(evt =>
{
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if (selectPackage != null)
{
selectPackage.PackageName = evt.newValue;
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
}
});
// 包裹备注
_packageDescTxt = root.Q<TextField>("PackageDesc");
_packageDescTxt.RegisterValueChangedCallback(evt =>
{
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if (selectPackage != null)
{
selectPackage.PackageDesc = evt.newValue;
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
}
}); });
// 分组列表相关 // 分组列表相关
@ -110,11 +174,12 @@ namespace YooAsset.Editor
_groupNameTxt = root.Q<TextField>("GroupName"); _groupNameTxt = root.Q<TextField>("GroupName");
_groupNameTxt.RegisterValueChangedCallback(evt => _groupNameTxt.RegisterValueChangedCallback(evt =>
{ {
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup; var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
if (selectGroup != null) if (selectPackage != null && selectGroup != null)
{ {
selectGroup.GroupName = evt.newValue; selectGroup.GroupName = evt.newValue;
AssetBundleCollectorSettingData.ModifyGroup(selectGroup); AssetBundleCollectorSettingData.ModifyGroup(selectPackage, selectGroup);
} }
}); });
@ -122,11 +187,12 @@ namespace YooAsset.Editor
_groupDescTxt = root.Q<TextField>("GroupDesc"); _groupDescTxt = root.Q<TextField>("GroupDesc");
_groupDescTxt.RegisterValueChangedCallback(evt => _groupDescTxt.RegisterValueChangedCallback(evt =>
{ {
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup; var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
if (selectGroup != null) if (selectPackage != null && selectGroup != null)
{ {
selectGroup.GroupDesc = evt.newValue; selectGroup.GroupDesc = evt.newValue;
AssetBundleCollectorSettingData.ModifyGroup(selectGroup); AssetBundleCollectorSettingData.ModifyGroup(selectPackage, selectGroup);
} }
}); });
@ -134,14 +200,18 @@ namespace YooAsset.Editor
_groupAssetTagsTxt = root.Q<TextField>("GroupAssetTags"); _groupAssetTagsTxt = root.Q<TextField>("GroupAssetTags");
_groupAssetTagsTxt.RegisterValueChangedCallback(evt => _groupAssetTagsTxt.RegisterValueChangedCallback(evt =>
{ {
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup; var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
if (selectGroup != null) if (selectPackage != null && selectGroup != null)
{ {
selectGroup.AssetTags = evt.newValue; selectGroup.AssetTags = evt.newValue;
AssetBundleCollectorSettingData.ModifyGroup(selectGroup); AssetBundleCollectorSettingData.ModifyGroup(selectPackage, selectGroup);
} }
}); });
// 收集列表容器
_collectorContainer = root.Q("CollectorContainer");
// 收集列表相关 // 收集列表相关
_collectorScrollView = root.Q<ScrollView>("CollectorScrollView"); _collectorScrollView = root.Q<ScrollView>("CollectorScrollView");
_collectorScrollView.style.height = new Length(100, LengthUnit.Percent); _collectorScrollView.style.height = new Length(100, LengthUnit.Percent);
@ -163,11 +233,12 @@ namespace YooAsset.Editor
activeRuleContainer.Add(_activeRulePopupField); activeRuleContainer.Add(_activeRulePopupField);
_activeRulePopupField.RegisterValueChangedCallback(evt => _activeRulePopupField.RegisterValueChangedCallback(evt =>
{ {
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup; var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
if (selectGroup != null) if (selectPackage != null && selectGroup != null)
{ {
selectGroup.ActiveRuleName = evt.newValue; selectGroup.ActiveRuleName = evt.newValue;
AssetBundleCollectorSettingData.ModifyGroup(selectGroup); AssetBundleCollectorSettingData.ModifyGroup(selectPackage, selectGroup);
FillGroupViewData(); FillGroupViewData();
} }
}); });
@ -208,10 +279,12 @@ namespace YooAsset.Editor
private void RefreshWindow() private void RefreshWindow()
{ {
_showPackageToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowPackageView);
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable); _enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable);
_groupContainer.visible = false; _groupContainer.visible = false;
_collectorContainer.visible = false;
FillGroupViewData(); FillPackageViewData();
} }
private void FixBtn_clicked() private void FixBtn_clicked()
{ {
@ -239,22 +312,97 @@ namespace YooAsset.Editor
AssetBundleCollectorSettingData.SaveFile(); AssetBundleCollectorSettingData.SaveFile();
} }
// 包裹列表相关
private void FillPackageViewData()
{
_packageListView.Clear();
_packageListView.ClearSelection();
_packageListView.itemsSource = AssetBundleCollectorSettingData.Setting.Packages;
_packageListView.Rebuild();
if (_lastModifyPackageIndex >= 0 && _lastModifyPackageIndex < _packageListView.itemsSource.Count)
{
_packageListView.selectedIndex = _lastModifyPackageIndex;
}
if (_showPackageToogle.value)
_packageContainer.style.display = DisplayStyle.Flex;
else
_packageContainer.style.display = DisplayStyle.None;
}
private VisualElement MakePackageListViewItem()
{
VisualElement element = new VisualElement();
{
var label = new Label();
label.name = "Label1";
label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.flexGrow = 1f;
label.style.height = 20f;
element.Add(label);
}
return element;
}
private void BindPackageListViewItem(VisualElement element, int index)
{
var package = AssetBundleCollectorSettingData.Setting.Packages[index];
var textField1 = element.Q<Label>("Label1");
if (string.IsNullOrEmpty(package.PackageDesc))
textField1.text = package.PackageName;
else
textField1.text = $"{package.PackageName} ({package.PackageDesc})";
}
private void PackageListView_onSelectionChange(IEnumerable<object> objs)
{
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if (selectPackage == null)
{
_groupContainer.visible = false;
_collectorContainer.visible = false;
return;
}
_groupContainer.visible = true;
_lastModifyPackageIndex = _packageListView.selectedIndex;
_packageNameTxt.SetValueWithoutNotify(selectPackage.PackageName);
_packageDescTxt.SetValueWithoutNotify(selectPackage.PackageDesc);
FillGroupViewData();
}
private void AddPackageBtn_clicked()
{
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow AddPackage");
AssetBundleCollectorSettingData.CreatePackage("Default Package");
FillPackageViewData();
}
private void RemovePackageBtn_clicked()
{
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if (selectPackage == null)
return;
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow RemovePackage");
AssetBundleCollectorSettingData.RemovePackage(selectPackage);
FillPackageViewData();
}
// 分组列表相关 // 分组列表相关
private void FillGroupViewData() private void FillGroupViewData()
{ {
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if (selectPackage == null)
return;
_groupListView.Clear(); _groupListView.Clear();
_groupListView.ClearSelection(); _groupListView.ClearSelection();
_groupListView.itemsSource = AssetBundleCollectorSettingData.Setting.Groups; _groupListView.itemsSource = selectPackage.Groups;
_groupListView.Rebuild(); _groupListView.Rebuild();
for (int index = 0; index < AssetBundleCollectorSettingData.Setting.Groups.Count; index++) if(_lastModifyGroupIndex >=0 && _lastModifyGroupIndex < _groupListView.itemsSource.Count)
{ {
var group = AssetBundleCollectorSettingData.Setting.Groups[index]; _groupListView.selectedIndex = _lastModifyGroupIndex;
if (group.GroupName == _lastModifyGroup)
{
_groupListView.selectedIndex = index;
break;
}
} }
} }
private VisualElement MakeGroupListViewItem() private VisualElement MakeGroupListViewItem()
@ -274,9 +422,12 @@ namespace YooAsset.Editor
} }
private void BindGroupListViewItem(VisualElement element, int index) private void BindGroupListViewItem(VisualElement element, int index)
{ {
var group = AssetBundleCollectorSettingData.Setting.Groups[index]; var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if (selectPackage == null)
return;
var group = selectPackage.Groups[index];
// Group Name
var textField1 = element.Q<Label>("Label1"); var textField1 = element.Q<Label>("Label1");
if (string.IsNullOrEmpty(group.GroupDesc)) if (string.IsNullOrEmpty(group.GroupDesc))
textField1.text = group.GroupName; textField1.text = group.GroupName;
@ -290,22 +441,44 @@ namespace YooAsset.Editor
} }
private void GroupListView_onSelectionChange(IEnumerable<object> objs) private void GroupListView_onSelectionChange(IEnumerable<object> objs)
{ {
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
if (selectGroup == null)
{
_collectorContainer.visible = false;
return;
}
_collectorContainer.visible = true;
_lastModifyGroupIndex = _groupListView.selectedIndex;
_activeRulePopupField.SetValueWithoutNotify(selectGroup.ActiveRuleName);
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
_groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
FillCollectorViewData(); FillCollectorViewData();
} }
private void AddGroupBtn_clicked() private void AddGroupBtn_clicked()
{ {
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if (selectPackage == null)
return;
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow AddGroup"); Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow AddGroup");
AssetBundleCollectorSettingData.CreateGroup("Default Group"); AssetBundleCollectorSettingData.CreateGroup(selectPackage, "Default Group");
FillGroupViewData(); FillGroupViewData();
} }
private void RemoveGroupBtn_clicked() private void RemoveGroupBtn_clicked()
{ {
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if (selectPackage == null)
return;
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup; var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
if (selectGroup == null) if (selectGroup == null)
return; return;
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow RemoveGroup"); Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow RemoveGroup");
AssetBundleCollectorSettingData.RemoveGroup(selectGroup); AssetBundleCollectorSettingData.RemoveGroup(selectPackage, selectGroup);
FillGroupViewData(); FillGroupViewData();
} }
@ -314,17 +487,7 @@ namespace YooAsset.Editor
{ {
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup; var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
if (selectGroup == null) if (selectGroup == null)
{
_groupContainer.visible = false;
return; return;
}
_lastModifyGroup = selectGroup.GroupName;
_groupContainer.visible = true;
_activeRulePopupField.SetValueWithoutNotify(selectGroup.ActiveRuleName);
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
_groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
// 填充数据 // 填充数据
_collectorScrollView.Clear(); _collectorScrollView.Clear();
@ -570,7 +733,8 @@ namespace YooAsset.Editor
try try
{ {
collectAssetInfos = collector.GetAllCollectAssets(EBuildMode.DryRunBuild, group); bool enableAdressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
collectAssetInfos = collector.GetAllCollectAssets(EBuildMode.DryRunBuild, enableAdressable, group);
} }
catch (System.Exception e) catch (System.Exception e)
{ {
@ -611,7 +775,8 @@ namespace YooAsset.Editor
return; return;
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow AddCollector"); Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow AddCollector");
AssetBundleCollectorSettingData.CreateCollector(selectGroup); AssetBundleCollector collector = new AssetBundleCollector();
AssetBundleCollectorSettingData.CreateCollector(selectGroup, collector);
FillCollectorViewData(); FillCollectorViewData();
} }
private void RemoveCollectorBtn_clicked(AssetBundleCollector selectCollector) private void RemoveCollectorBtn_clicked(AssetBundleCollector selectCollector)

View File

@ -5,19 +5,31 @@
<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="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);" /> <ui:Button text="修复" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
</uie:Toolbar> </uie:Toolbar>
<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="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
</ui:VisualElement>
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;"> <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;"> <ui:VisualElement name="PackageContainer" 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;">
<ui:Label text="Packages" display-tooltip-when-elided="true" name="PackageTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
<ui:ListView focusable="true" name="PackageListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
<ui:VisualElement name="PackageAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement name="GroupContainer" 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;">
<ui:Label text="Groups" display-tooltip-when-elided="true" name="GroupTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
<ui:TextField picking-mode="Ignore" label="Package Name" value="filler text" name="PackageName" style="flex-direction: column;" />
<ui:TextField picking-mode="Ignore" label="Package Desc" value="filler text" name="PackageDesc" style="flex-direction: column;" />
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" /> <ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
<ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center;"> <ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" /> <ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" /> <ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="RightContainer" style="flex-direction: column; flex-grow: 1;"> <ui:VisualElement name="CollectorContainer" style="flex-grow: 1; 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:Label text="Collectors" display-tooltip-when-elided="true" name="CollectorTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -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;" /> <ui:VisualElement name="ActiveRuleContainer" style="height: 20px;" />
<ui:TextField picking-mode="Ignore" label="Group Name" name="GroupName" /> <ui:TextField picking-mode="Ignore" label="Group Name" name="GroupName" />
<ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" /> <ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" />
@ -28,5 +40,4 @@
<ui:ScrollView name="CollectorScrollView" style="flex-grow: 1;" /> <ui:ScrollView name="CollectorScrollView" style="flex-grow: 1;" />
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement>
</ui:UXML> </ui:UXML>

View File

@ -87,7 +87,7 @@ namespace YooAsset.Editor
List<string> allAssets = new List<string>(1000); List<string> allAssets = new List<string>(1000);
// 获取所有打包的资源 // 获取所有打包的资源
List<CollectAssetInfo> allCollectInfos = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets(EBuildMode.DryRunBuild); List<CollectAssetInfo> allCollectInfos = AssetBundleCollectorSettingData.Setting.GetAllPackageAssets(EBuildMode.DryRunBuild);
List<string> collectAssets = allCollectInfos.Select(t => t.AssetPath).ToList(); List<string> collectAssets = allCollectInfos.Select(t => t.AssetPath).ToList();
foreach (var assetPath in collectAssets) foreach (var assetPath in collectAssets)
{ {