parent
d592fb96a6
commit
eafdb8cd31
|
@ -176,7 +176,7 @@ namespace YooAsset.Editor
|
|||
buildParameters.BuildVersion = _buildVersionField.value;
|
||||
buildParameters.BuildinTags = _buildTagsField.value;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.EnableAddressable = AssetBundleGrouperSettingData.Setting.EnableAddressable;
|
||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||
buildParameters.AppendFileExtension = _appendExtensionToggle.value;
|
||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||
buildParameters.CompressOption = (ECompressOption)_compressionField.value;
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace YooAsset.Editor
|
|||
buildParameters.BuildMode = EBuildMode.FastRunBuild;
|
||||
buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion;
|
||||
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
|
||||
buildParameters.EnableAddressable = AssetBundleGrouperSettingData.Setting.EnableAddressable;
|
||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
bool buildResult = builder.Run(buildParameters);
|
||||
|
|
|
@ -147,11 +147,11 @@ namespace YooAsset.Editor
|
|||
if (IsRawAsset)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
||||
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
||||
{
|
||||
if (IsShaderAsset)
|
||||
{
|
||||
string shareBundleName = $"{AssetBundleGrouperSettingData.Setting.ShadersBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
||||
string shareBundleName = $"{AssetBundleCollectorSettingData.Setting.ShadersBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ namespace YooAsset.Editor
|
|||
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
||||
|
||||
// 1. 检测配置合法性
|
||||
AssetBundleGrouperSettingData.Setting.CheckConfigError();
|
||||
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
||||
|
||||
// 2. 获取所有主动收集的资源
|
||||
List<CollectAssetInfo> allCollectAssets = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
||||
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets();
|
||||
|
||||
// 3. 剔除未被引用的依赖资源
|
||||
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace YooAsset.Editor
|
|||
buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable;
|
||||
buildReport.Summary.EnableAutoCollect = buildParameters.Parameters.EnableAutoCollect;
|
||||
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
||||
buildReport.Summary.AutoCollectShaders = AssetBundleGrouperSettingData.Setting.AutoCollectShaders;
|
||||
buildReport.Summary.ShadersBundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName;
|
||||
buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders;
|
||||
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?
|
||||
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
|
||||
|
||||
|
|
|
@ -51,13 +51,13 @@ namespace YooAsset.Editor
|
|||
if (CollectorType == ECollectorType.None)
|
||||
return false;
|
||||
|
||||
if (AssetBundleGrouperSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
return false;
|
||||
|
||||
if (AssetBundleGrouperSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
return false;
|
||||
|
||||
if (AssetBundleGrouperSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -74,20 +74,20 @@ namespace YooAsset.Editor
|
|||
if (CollectorType == ECollectorType.None)
|
||||
throw new Exception($"{nameof(ECollectorType)}.{ECollectorType.None} is invalid in collector : {CollectPath}");
|
||||
|
||||
if (AssetBundleGrouperSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IPackRule)} class type : {PackRuleName} in collector : {CollectPath}");
|
||||
|
||||
if (AssetBundleGrouperSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IFilterRule)} class type : {FilterRuleName} in collector : {CollectPath}");
|
||||
|
||||
if (AssetBundleGrouperSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IAddressRule)} class type : {AddressRuleName} in collector : {CollectPath}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(AssetBundleGrouper grouper)
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(AssetBundleCollectorGroup group)
|
||||
{
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
||||
bool isRawAsset = PackRuleName == nameof(PackRawFile);
|
||||
|
@ -97,7 +97,7 @@ namespace YooAsset.Editor
|
|||
throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}");
|
||||
|
||||
if (string.IsNullOrEmpty(CollectPath))
|
||||
throw new Exception($"The collect path is null or empty in grouper : {grouper.GrouperName}");
|
||||
throw new Exception($"The collect path is null or empty in group : {group.GroupName}");
|
||||
|
||||
// 收集打包资源
|
||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||
|
@ -110,7 +110,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
if (result.ContainsKey(assetPath) == false)
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(grouper, assetPath, isRawAsset);
|
||||
var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
|
@ -125,7 +125,7 @@ namespace YooAsset.Editor
|
|||
string assetPath = CollectPath;
|
||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(grouper, assetPath, isRawAsset);
|
||||
var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
|
@ -135,7 +135,7 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (AssetBundleGrouperSettingData.Setting.EnableAddressable)
|
||||
if (AssetBundleCollectorSettingData.Setting.EnableAddressable)
|
||||
{
|
||||
HashSet<string> adressTemper = new HashSet<string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
|
@ -155,11 +155,11 @@ namespace YooAsset.Editor
|
|||
return result.Values.ToList();
|
||||
}
|
||||
|
||||
private CollectAssetInfo CreateCollectAssetInfo(AssetBundleGrouper grouper, string assetPath, bool isRawAsset)
|
||||
private CollectAssetInfo CreateCollectAssetInfo(AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
|
||||
{
|
||||
string address = GetAddress(grouper, assetPath);
|
||||
string bundleName = GetBundleName(grouper, assetPath);
|
||||
List<string> assetTags = GetAssetTags(grouper);
|
||||
string address = GetAddress(group, assetPath);
|
||||
string bundleName = GetBundleName(group, assetPath);
|
||||
List<string> assetTags = GetAssetTags(group);
|
||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
||||
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
||||
return collectAssetInfo;
|
||||
|
@ -186,7 +186,7 @@ namespace YooAsset.Editor
|
|||
private bool IsCollectAsset(string assetPath)
|
||||
{
|
||||
// 如果收集全路径着色器
|
||||
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
||||
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
||||
{
|
||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
|
@ -194,41 +194,41 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 根据规则设置过滤资源文件
|
||||
IFilterRule filterRuleInstance = AssetBundleGrouperSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath));
|
||||
}
|
||||
private string GetAddress(AssetBundleGrouper grouper, string assetPath)
|
||||
private string GetAddress(AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||
return string.Empty;
|
||||
|
||||
IAddressRule addressRuleInstance = AssetBundleGrouperSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, grouper.GrouperName));
|
||||
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName));
|
||||
return adressValue;
|
||||
}
|
||||
private string GetBundleName(AssetBundleGrouper grouper, string assetPath)
|
||||
private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
// 如果自动收集所有的着色器
|
||||
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
||||
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
||||
{
|
||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
{
|
||||
string bundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName;
|
||||
string bundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
||||
}
|
||||
}
|
||||
|
||||
// 根据规则设置获取资源包名称
|
||||
{
|
||||
IPackRule packRuleInstance = AssetBundleGrouperSettingData.GetPackRuleInstance(PackRuleName);
|
||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, grouper.GrouperName));
|
||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName));
|
||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
||||
}
|
||||
}
|
||||
private List<string> GetAssetTags(AssetBundleGrouper grouper)
|
||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||
{
|
||||
List<string> tags = StringUtility.StringToStringList(grouper.AssetTags, ';');
|
||||
List<string> tags = StringUtility.StringToStringList(group.AssetTags, ';');
|
||||
List<string> temper = StringUtility.StringToStringList(AssetTags, ';');
|
||||
tags.AddRange(temper);
|
||||
return tags;
|
|
@ -8,14 +8,14 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleGrouperConfig
|
||||
public class AssetBundleCollectorConfig
|
||||
{
|
||||
public const string XmlShader = "Shader";
|
||||
public const string XmlAutoCollectShader = "AutoCollectShader";
|
||||
public const string XmlShaderBundleName = "ShaderBundleName";
|
||||
public const string XmlGrouper = "Grouper";
|
||||
public const string XmlGrouperName = "GrouperName";
|
||||
public const string XmlGrouperDesc = "GrouperDesc";
|
||||
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 XmlCollectorType = "CollectType";
|
||||
|
@ -57,26 +57,26 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 读取分组配置
|
||||
List<AssetBundleGrouper> grouperTemper = new List<AssetBundleGrouper>();
|
||||
var grouperNodeList = root.GetElementsByTagName(XmlGrouper);
|
||||
foreach (var grouperNode in grouperNodeList)
|
||||
List<AssetBundleCollectorGroup> groupTemper = new List<AssetBundleCollectorGroup>();
|
||||
var groupNodeList = root.GetElementsByTagName(XmlGroup);
|
||||
foreach (var groupNode in groupNodeList)
|
||||
{
|
||||
XmlElement grouperElement = grouperNode as XmlElement;
|
||||
if (grouperElement.HasAttribute(XmlGrouperName) == false)
|
||||
throw new Exception($"Not found attribute {XmlGrouperName} in {XmlGrouper}");
|
||||
if (grouperElement.HasAttribute(XmlGrouperDesc) == false)
|
||||
throw new Exception($"Not found attribute {XmlGrouperDesc} in {XmlGrouper}");
|
||||
if (grouperElement.HasAttribute(XmlAssetTags) == false)
|
||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGrouper}");
|
||||
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}");
|
||||
|
||||
AssetBundleGrouper grouper = new AssetBundleGrouper();
|
||||
grouper.GrouperName = grouperElement.GetAttribute(XmlGrouperName);
|
||||
grouper.GrouperDesc = grouperElement.GetAttribute(XmlGrouperDesc);
|
||||
grouper.AssetTags = grouperElement.GetAttribute(XmlAssetTags);
|
||||
grouperTemper.Add(grouper);
|
||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||
group.GroupName = groupElement.GetAttribute(XmlGroupName);
|
||||
group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc);
|
||||
group.AssetTags = groupElement.GetAttribute(XmlAssetTags);
|
||||
groupTemper.Add(group);
|
||||
|
||||
// 读取收集器配置
|
||||
var collectorNodeList = grouperElement.GetElementsByTagName(XmlCollector);
|
||||
var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
|
||||
foreach (var collectorNode in collectorNodeList)
|
||||
{
|
||||
XmlElement collectorElement = collectorNode as XmlElement;
|
||||
|
@ -100,16 +100,16 @@ namespace YooAsset.Editor
|
|||
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
||||
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
||||
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags); ;
|
||||
grouper.Collectors.Add(collector);
|
||||
group.Collectors.Add(collector);
|
||||
}
|
||||
}
|
||||
|
||||
// 保存配置数据
|
||||
AssetBundleGrouperSettingData.ClearAll();
|
||||
AssetBundleGrouperSettingData.Setting.AutoCollectShaders = autoCollectShaders;
|
||||
AssetBundleGrouperSettingData.Setting.ShadersBundleName = shaderBundleName;
|
||||
AssetBundleGrouperSettingData.Setting.Groupers.AddRange(grouperTemper);
|
||||
AssetBundleGrouperSettingData.SaveFile();
|
||||
AssetBundleCollectorSettingData.ClearAll();
|
||||
AssetBundleCollectorSettingData.Setting.AutoCollectShaders = autoCollectShaders;
|
||||
AssetBundleCollectorSettingData.Setting.ShadersBundleName = shaderBundleName;
|
||||
AssetBundleCollectorSettingData.Setting.Groups.AddRange(groupTemper);
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
Debug.Log($"导入配置完毕!");
|
||||
}
|
||||
|
||||
|
@ -132,20 +132,20 @@ namespace YooAsset.Editor
|
|||
|
||||
// 设置着色器配置
|
||||
var shaderElement = xmlDoc.CreateElement(XmlShader);
|
||||
shaderElement.SetAttribute(XmlAutoCollectShader, AssetBundleGrouperSettingData.Setting.AutoCollectShaders.ToString());
|
||||
shaderElement.SetAttribute(XmlShaderBundleName, AssetBundleGrouperSettingData.Setting.ShadersBundleName);
|
||||
shaderElement.SetAttribute(XmlAutoCollectShader, AssetBundleCollectorSettingData.Setting.AutoCollectShaders.ToString());
|
||||
shaderElement.SetAttribute(XmlShaderBundleName, AssetBundleCollectorSettingData.Setting.ShadersBundleName);
|
||||
|
||||
// 设置分组配置
|
||||
foreach (var grouper in AssetBundleGrouperSettingData.Setting.Groupers)
|
||||
foreach (var group in AssetBundleCollectorSettingData.Setting.Groups)
|
||||
{
|
||||
var grouperElement = xmlDoc.CreateElement(XmlGrouper);
|
||||
grouperElement.SetAttribute(XmlGrouperName, grouper.GrouperName);
|
||||
grouperElement.SetAttribute(XmlGrouperDesc, grouper.GrouperDesc);
|
||||
grouperElement.SetAttribute(XmlAssetTags, grouper.AssetTags);
|
||||
root.AppendChild(grouperElement);
|
||||
var groupElement = xmlDoc.CreateElement(XmlGroup);
|
||||
groupElement.SetAttribute(XmlGroupName, group.GroupName);
|
||||
groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc);
|
||||
groupElement.SetAttribute(XmlAssetTags, group.AssetTags);
|
||||
root.AppendChild(groupElement);
|
||||
|
||||
// 设置收集器配置
|
||||
foreach (var collector in grouper.Collectors)
|
||||
foreach (var collector in group.Collectors)
|
||||
{
|
||||
var collectorElement = xmlDoc.CreateElement(XmlCollector);
|
||||
collectorElement.SetAttribute(XmlCollectPath, collector.CollectPath);
|
||||
|
@ -154,7 +154,7 @@ namespace YooAsset.Editor
|
|||
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
||||
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
||||
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
||||
grouperElement.AppendChild(collectorElement);
|
||||
groupElement.AppendChild(collectorElement);
|
||||
}
|
||||
}
|
||||
|
|
@ -8,17 +8,17 @@ using UnityEditor;
|
|||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetBundleGrouper
|
||||
public class AssetBundleCollectorGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// 分组名称
|
||||
/// </summary>
|
||||
public string GrouperName = string.Empty;
|
||||
public string GroupName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 分组描述
|
||||
/// </summary>
|
||||
public string GrouperDesc = string.Empty;
|
||||
public string GroupDesc = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 资源分类标签
|
||||
|
@ -58,12 +58,12 @@ namespace YooAsset.Editor
|
|||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||
result.Add(assetInfo.AssetPath, assetInfo);
|
||||
else
|
||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in grouper : {GrouperName}");
|
||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group : {GroupName}");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (AssetBundleGrouperSettingData.Setting.EnableAddressable)
|
||||
if (AssetBundleCollectorSettingData.Setting.EnableAddressable)
|
||||
{
|
||||
HashSet<string> adressTemper = new HashSet<string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
|
@ -74,7 +74,7 @@ namespace YooAsset.Editor
|
|||
if (adressTemper.Contains(address) == false)
|
||||
adressTemper.Add(address);
|
||||
else
|
||||
throw new Exception($"The address is existed : {address} in grouper : {GrouperName}");
|
||||
throw new Exception($"The address is existed : {address} in group : {GroupName}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleGrouperSetting : ScriptableObject
|
||||
public class AssetBundleCollectorSetting : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否启用可寻址资源定位
|
||||
|
@ -26,7 +26,7 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 分组列表
|
||||
/// </summary>
|
||||
public List<AssetBundleGrouper> Groupers = new List<AssetBundleGrouper>();
|
||||
public List<AssetBundleCollectorGroup> Groups = new List<AssetBundleCollectorGroup>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -34,9 +34,9 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
foreach (var grouper in Groupers)
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
grouper.CheckConfigError();
|
||||
group.CheckConfigError();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,15 +48,15 @@ namespace YooAsset.Editor
|
|||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||
|
||||
// 收集打包资源
|
||||
foreach (var grouper in Groupers)
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
var temper = grouper.GetAllCollectAssets();
|
||||
var temper = group.GetAllCollectAssets();
|
||||
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} in grouper setting.");
|
||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group setting.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ namespace YooAsset.Editor
|
|||
if (adressTemper.Contains(address) == false)
|
||||
adressTemper.Add(address);
|
||||
else
|
||||
throw new Exception($"The address is existed : {address} in grouper setting.");
|
||||
throw new Exception($"The address is existed : {address} in group setting.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleGrouperSettingData
|
||||
public class AssetBundleCollectorSettingData
|
||||
{
|
||||
private static readonly Dictionary<string, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>();
|
||||
private static readonly Dictionary<string, IAddressRule> _cacheAddressRuleInstance = new Dictionary<string, IAddressRule>();
|
||||
|
@ -24,8 +24,8 @@ namespace YooAsset.Editor
|
|||
public static bool IsDirty { private set; get; } = false;
|
||||
|
||||
|
||||
private static AssetBundleGrouperSetting _setting = null;
|
||||
public static AssetBundleGrouperSetting Setting
|
||||
private static AssetBundleCollectorSetting _setting = null;
|
||||
public static AssetBundleCollectorSetting Setting
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -106,12 +106,12 @@ namespace YooAsset.Editor
|
|||
private static void LoadSettingData()
|
||||
{
|
||||
// 加载配置文件
|
||||
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleGrouperSetting)}.asset";
|
||||
_setting = AssetDatabase.LoadAssetAtPath<AssetBundleGrouperSetting>(settingFilePath);
|
||||
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleCollectorSetting)}.asset";
|
||||
_setting = AssetDatabase.LoadAssetAtPath<AssetBundleCollectorSetting>(settingFilePath);
|
||||
if (_setting == null)
|
||||
{
|
||||
Debug.LogWarning($"Create new {nameof(AssetBundleGrouperSetting)}.asset : {settingFilePath}");
|
||||
_setting = ScriptableObject.CreateInstance<AssetBundleGrouperSetting>();
|
||||
Debug.LogWarning($"Create new {nameof(AssetBundleCollectorSetting)}.asset : {settingFilePath}");
|
||||
_setting = ScriptableObject.CreateInstance<AssetBundleCollectorSetting>();
|
||||
EditorTools.CreateFileDirectory(settingFilePath);
|
||||
AssetDatabase.CreateAsset(Setting, settingFilePath);
|
||||
AssetDatabase.SaveAssets();
|
||||
|
@ -119,7 +119,7 @@ namespace YooAsset.Editor
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"Load {nameof(AssetBundleGrouperSetting)}.asset ok");
|
||||
Debug.Log($"Load {nameof(AssetBundleCollectorSetting)}.asset ok");
|
||||
}
|
||||
|
||||
// IPackRule
|
||||
|
@ -135,7 +135,7 @@ namespace YooAsset.Editor
|
|||
typeof(PackDirectory),
|
||||
typeof(PackTopDirectory),
|
||||
typeof(PackCollector),
|
||||
typeof(PackGrouper),
|
||||
typeof(PackGroup),
|
||||
typeof(PackRawFile),
|
||||
};
|
||||
|
||||
|
@ -187,7 +187,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
typeof(AddressByFileName),
|
||||
typeof(AddressByCollectorAndFileName),
|
||||
typeof(AddressByGrouperAndFileName)
|
||||
typeof(AddressByGroupAndFileName)
|
||||
};
|
||||
|
||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IAddressRule>();
|
||||
|
@ -212,7 +212,7 @@ namespace YooAsset.Editor
|
|||
IsDirty = false;
|
||||
EditorUtility.SetDirty(Setting);
|
||||
AssetDatabase.SaveAssets();
|
||||
Debug.Log($"{nameof(AssetBundleGrouperSetting)}.asset is saved!");
|
||||
Debug.Log($"{nameof(AssetBundleCollectorSetting)}.asset is saved!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
Setting.AutoCollectShaders = false;
|
||||
Setting.ShadersBundleName = string.Empty;
|
||||
Setting.Groupers.Clear();
|
||||
Setting.Groups.Clear();
|
||||
SaveFile();
|
||||
}
|
||||
|
||||
|
@ -296,43 +296,43 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 资源分组编辑相关
|
||||
public static void CreateGrouper(string grouperName)
|
||||
public static void CreateGroup(string groupName)
|
||||
{
|
||||
AssetBundleGrouper grouper = new AssetBundleGrouper();
|
||||
grouper.GrouperName = grouperName;
|
||||
Setting.Groupers.Add(grouper);
|
||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||
group.GroupName = groupName;
|
||||
Setting.Groups.Add(group);
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void RemoveGrouper(AssetBundleGrouper grouper)
|
||||
public static void RemoveGroup(AssetBundleCollectorGroup group)
|
||||
{
|
||||
if (Setting.Groupers.Remove(grouper))
|
||||
if (Setting.Groups.Remove(group))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove grouper : {grouper.GrouperName}");
|
||||
Debug.LogWarning($"Failed remove group : {group.GroupName}");
|
||||
}
|
||||
}
|
||||
public static void ModifyGrouper(AssetBundleGrouper grouper)
|
||||
public static void ModifyGroup(AssetBundleCollectorGroup group)
|
||||
{
|
||||
if (grouper != null)
|
||||
if (group != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 资源收集器编辑相关
|
||||
public static void CreateCollector(AssetBundleGrouper grouper, string collectPath)
|
||||
public static void CreateCollector(AssetBundleCollectorGroup group, string collectPath)
|
||||
{
|
||||
AssetBundleCollector collector = new AssetBundleCollector();
|
||||
collector.CollectPath = collectPath;
|
||||
grouper.Collectors.Add(collector);
|
||||
group.Collectors.Add(collector);
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void RemoveCollector(AssetBundleGrouper grouper, AssetBundleCollector collector)
|
||||
public static void RemoveCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
if (grouper.Collectors.Remove(collector))
|
||||
if (group.Collectors.Remove(collector))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
|
@ -341,9 +341,9 @@ namespace YooAsset.Editor
|
|||
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
||||
}
|
||||
}
|
||||
public static void ModifyCollector(AssetBundleGrouper grouper, AssetBundleCollector collector)
|
||||
public static void ModifyCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
if (grouper != null && collector != null)
|
||||
if (group != null && collector != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
|
@ -9,12 +9,12 @@ using UnityEngine.UIElements;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleGrouperWindow : EditorWindow
|
||||
public class AssetBundleCollectorWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Grouper", false, 101)]
|
||||
[MenuItem("YooAsset/AssetBundle Collector", false, 101)]
|
||||
public static void ShowExample()
|
||||
{
|
||||
AssetBundleGrouperWindow window = GetWindow<AssetBundleGrouperWindow>("资源包分组工具", true, EditorDefine.DockedWindowTypes);
|
||||
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("资源包收集工具", true, EditorDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
|
@ -22,15 +22,15 @@ namespace YooAsset.Editor
|
|||
private List<string> _addressRuleList;
|
||||
private List<string> _packRuleList;
|
||||
private List<string> _filterRuleList;
|
||||
private ListView _grouperListView;
|
||||
private ListView _groupListView;
|
||||
private ScrollView _collectorScrollView;
|
||||
private Toggle _enableAddressableToogle;
|
||||
private Toggle _autoCollectShaderToogle;
|
||||
private TextField _shaderBundleNameTxt;
|
||||
private TextField _grouperNameTxt;
|
||||
private TextField _grouperDescTxt;
|
||||
private TextField _grouperAssetTagsTxt;
|
||||
private VisualElement _grouperContainer;
|
||||
private TextField _groupNameTxt;
|
||||
private TextField _groupDescTxt;
|
||||
private TextField _groupAssetTagsTxt;
|
||||
private VisualElement _groupContainer;
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
|
@ -45,17 +45,17 @@ namespace YooAsset.Editor
|
|||
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
||||
$"{nameof(ECollectorType.DependAssetCollector)}"
|
||||
};
|
||||
_addressRuleList = AssetBundleGrouperSettingData.GetAddressRuleNames();
|
||||
_packRuleList = AssetBundleGrouperSettingData.GetPackRuleNames();
|
||||
_filterRuleList = AssetBundleGrouperSettingData.GetFilterRuleNames();
|
||||
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
||||
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
||||
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
||||
|
||||
// 加载布局文件
|
||||
string rootPath = EditorTools.GetYooAssetSourcePath();
|
||||
string uxml = $"{rootPath}/Editor/AssetBundleGrouper/{nameof(AssetBundleGrouperWindow)}.uxml";
|
||||
string uxml = $"{rootPath}/Editor/AssetBundleCollector/{nameof(AssetBundleCollectorWindow)}.uxml";
|
||||
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
|
||||
if (visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(AssetBundleGrouperWindow)}.uxml : {uxml}");
|
||||
Debug.LogError($"Not found {nameof(AssetBundleCollectorWindow)}.uxml : {uxml}");
|
||||
return;
|
||||
}
|
||||
visualAsset.CloneTree(root);
|
||||
|
@ -72,75 +72,75 @@ namespace YooAsset.Editor
|
|||
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable");
|
||||
_enableAddressableToogle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleGrouperSettingData.ModifyAddressable(evt.newValue);
|
||||
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
||||
});
|
||||
_autoCollectShaderToogle = root.Q<Toggle>("AutoCollectShader");
|
||||
_autoCollectShaderToogle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleGrouperSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value);
|
||||
AssetBundleCollectorSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value);
|
||||
_shaderBundleNameTxt.SetEnabled(evt.newValue);
|
||||
});
|
||||
_shaderBundleNameTxt = root.Q<TextField>("ShaderBundleName");
|
||||
_shaderBundleNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleGrouperSettingData.ModifyShader(_autoCollectShaderToogle.value, evt.newValue);
|
||||
AssetBundleCollectorSettingData.ModifyShader(_autoCollectShaderToogle.value, evt.newValue);
|
||||
});
|
||||
|
||||
// 分组列表相关
|
||||
_grouperListView = root.Q<ListView>("GrouperListView");
|
||||
_grouperListView.makeItem = MakeGrouperListViewItem;
|
||||
_grouperListView.bindItem = BindGrouperListViewItem;
|
||||
_groupListView = root.Q<ListView>("GroupListView");
|
||||
_groupListView.makeItem = MakeGroupListViewItem;
|
||||
_groupListView.bindItem = BindGroupListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_grouperListView.onSelectionChange += GrouperListView_onSelectionChange;
|
||||
_groupListView.onSelectionChange += GroupListView_onSelectionChange;
|
||||
#else
|
||||
_grouperListView.onSelectionChanged += GrouperListView_onSelectionChange;
|
||||
_groupListView.onSelectionChanged += GroupListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 分组添加删除按钮
|
||||
var grouperAddContainer = root.Q("GrouperAddContainer");
|
||||
var groupAddContainer = root.Q("GroupAddContainer");
|
||||
{
|
||||
var addBtn = grouperAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddGrouperBtn_clicked;
|
||||
var removeBtn = grouperAddContainer.Q<Button>("RemoveBtn");
|
||||
removeBtn.clicked += RemoveGrouperBtn_clicked;
|
||||
var addBtn = groupAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddGroupBtn_clicked;
|
||||
var removeBtn = groupAddContainer.Q<Button>("RemoveBtn");
|
||||
removeBtn.clicked += RemoveGroupBtn_clicked;
|
||||
}
|
||||
|
||||
// 分组容器
|
||||
_grouperContainer = root.Q("GrouperContainer");
|
||||
_groupContainer = root.Q("GroupContainer");
|
||||
|
||||
// 分组名称
|
||||
_grouperNameTxt = root.Q<TextField>("GrouperName");
|
||||
_grouperNameTxt.RegisterValueChangedCallback(evt =>
|
||||
_groupNameTxt = root.Q<TextField>("GroupName");
|
||||
_groupNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper != null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup != null)
|
||||
{
|
||||
selectGrouper.GrouperName = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyGrouper(selectGrouper);
|
||||
selectGroup.GroupName = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||
}
|
||||
});
|
||||
|
||||
// 分组备注
|
||||
_grouperDescTxt = root.Q<TextField>("GrouperDesc");
|
||||
_grouperDescTxt.RegisterValueChangedCallback(evt =>
|
||||
_groupDescTxt = root.Q<TextField>("GroupDesc");
|
||||
_groupDescTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper != null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup != null)
|
||||
{
|
||||
selectGrouper.GrouperDesc = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyGrouper(selectGrouper);
|
||||
selectGroup.GroupDesc = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||
}
|
||||
});
|
||||
|
||||
// 分组的资源标签
|
||||
_grouperAssetTagsTxt = root.Q<TextField>("GrouperAssetTags");
|
||||
_grouperAssetTagsTxt.RegisterValueChangedCallback(evt =>
|
||||
_groupAssetTagsTxt = root.Q<TextField>("GroupAssetTags");
|
||||
_groupAssetTagsTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper != null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup != null)
|
||||
{
|
||||
selectGrouper.AssetTags = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyGrouper(selectGrouper);
|
||||
selectGroup.AssetTags = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -166,26 +166,26 @@ namespace YooAsset.Editor
|
|||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
if (AssetBundleGrouperSettingData.IsDirty)
|
||||
AssetBundleGrouperSettingData.SaveFile();
|
||||
if (AssetBundleCollectorSettingData.IsDirty)
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
}
|
||||
|
||||
private void RefreshWindow()
|
||||
{
|
||||
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleGrouperSettingData.Setting.EnableAddressable);
|
||||
_autoCollectShaderToogle.SetValueWithoutNotify(AssetBundleGrouperSettingData.Setting.AutoCollectShaders);
|
||||
_shaderBundleNameTxt.SetEnabled(AssetBundleGrouperSettingData.Setting.AutoCollectShaders);
|
||||
_shaderBundleNameTxt.SetValueWithoutNotify(AssetBundleGrouperSettingData.Setting.ShadersBundleName);
|
||||
_grouperContainer.visible = false;
|
||||
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable);
|
||||
_autoCollectShaderToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.AutoCollectShaders);
|
||||
_shaderBundleNameTxt.SetEnabled(AssetBundleCollectorSettingData.Setting.AutoCollectShaders);
|
||||
_shaderBundleNameTxt.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShadersBundleName);
|
||||
_groupContainer.visible = false;
|
||||
|
||||
FillGrouperViewData();
|
||||
FillGroupViewData();
|
||||
}
|
||||
private void ExportBtn_clicked()
|
||||
{
|
||||
string resultPath = EditorTools.OpenFolderPanel("Export XML", "Assets/");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetBundleGrouperConfig.ExportXmlConfig($"{resultPath}/{nameof(AssetBundleGrouperConfig)}.xml");
|
||||
AssetBundleCollectorConfig.ExportXmlConfig($"{resultPath}/{nameof(AssetBundleCollectorConfig)}.xml");
|
||||
}
|
||||
}
|
||||
private void ImportBtn_clicked()
|
||||
|
@ -193,20 +193,20 @@ namespace YooAsset.Editor
|
|||
string resultPath = EditorTools.OpenFilePath("Import XML", "Assets/", "xml");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetBundleGrouperConfig.ImportXmlConfig(resultPath);
|
||||
AssetBundleCollectorConfig.ImportXmlConfig(resultPath);
|
||||
RefreshWindow();
|
||||
}
|
||||
}
|
||||
|
||||
// 分组列表相关
|
||||
private void FillGrouperViewData()
|
||||
private void FillGroupViewData()
|
||||
{
|
||||
_grouperListView.Clear();
|
||||
_grouperListView.ClearSelection();
|
||||
_grouperListView.itemsSource = AssetBundleGrouperSettingData.Setting.Groupers;
|
||||
_grouperListView.Rebuild();
|
||||
_groupListView.Clear();
|
||||
_groupListView.ClearSelection();
|
||||
_groupListView.itemsSource = AssetBundleCollectorSettingData.Setting.Groups;
|
||||
_groupListView.Rebuild();
|
||||
}
|
||||
private VisualElement MakeGrouperListViewItem()
|
||||
private VisualElement MakeGroupListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
|
||||
|
@ -221,57 +221,57 @@ namespace YooAsset.Editor
|
|||
|
||||
return element;
|
||||
}
|
||||
private void BindGrouperListViewItem(VisualElement element, int index)
|
||||
private void BindGroupListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var grouper = AssetBundleGrouperSettingData.Setting.Groupers[index];
|
||||
var group = AssetBundleCollectorSettingData.Setting.Groups[index];
|
||||
|
||||
// Grouper Name
|
||||
// Group Name
|
||||
var textField1 = element.Q<Label>("Label1");
|
||||
if (string.IsNullOrEmpty(grouper.GrouperDesc))
|
||||
textField1.text = grouper.GrouperName;
|
||||
if (string.IsNullOrEmpty(group.GroupDesc))
|
||||
textField1.text = group.GroupName;
|
||||
else
|
||||
textField1.text = $"{grouper.GrouperName} ({grouper.GrouperDesc})";
|
||||
textField1.text = $"{group.GroupName} ({group.GroupDesc})";
|
||||
}
|
||||
private void GrouperListView_onSelectionChange(IEnumerable<object> objs)
|
||||
private void GroupListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void AddGrouperBtn_clicked()
|
||||
private void AddGroupBtn_clicked()
|
||||
{
|
||||
Undo.RecordObject(AssetBundleGrouperSettingData.Setting, "YooAsset AddGrouper");
|
||||
AssetBundleGrouperSettingData.CreateGrouper("Default Grouper");
|
||||
FillGrouperViewData();
|
||||
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset AddGroup");
|
||||
AssetBundleCollectorSettingData.CreateGroup("Default Group");
|
||||
FillGroupViewData();
|
||||
}
|
||||
private void RemoveGrouperBtn_clicked()
|
||||
private void RemoveGroupBtn_clicked()
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper == null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetBundleGrouperSettingData.Setting, "YooAsset RemoveGrouper");
|
||||
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset RemoveGroup");
|
||||
|
||||
AssetBundleGrouperSettingData.RemoveGrouper(selectGrouper);
|
||||
FillGrouperViewData();
|
||||
AssetBundleCollectorSettingData.RemoveGroup(selectGroup);
|
||||
FillGroupViewData();
|
||||
}
|
||||
|
||||
// 收集列表相关
|
||||
private void FillCollectorViewData()
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper == null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
{
|
||||
_grouperContainer.visible = false;
|
||||
_groupContainer.visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_grouperContainer.visible = true;
|
||||
_grouperNameTxt.SetValueWithoutNotify(selectGrouper.GrouperName);
|
||||
_grouperDescTxt.SetValueWithoutNotify(selectGrouper.GrouperDesc);
|
||||
_grouperAssetTagsTxt.SetValueWithoutNotify(selectGrouper.AssetTags);
|
||||
_groupContainer.visible = true;
|
||||
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
|
||||
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
|
||||
_groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
|
||||
|
||||
// 填充数据
|
||||
_collectorScrollView.Clear();
|
||||
for (int i = 0; i < selectGrouper.Collectors.Count; i++)
|
||||
for (int i = 0; i < selectGroup.Collectors.Count; i++)
|
||||
{
|
||||
VisualElement element = MakeCollectorListViewItem();
|
||||
BindCollectorListViewItem(element, i);
|
||||
|
@ -391,11 +391,11 @@ namespace YooAsset.Editor
|
|||
}
|
||||
private void BindCollectorListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper == null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
|
||||
var collector = selectGrouper.Collectors[index];
|
||||
var collector = selectGroup.Collectors[index];
|
||||
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||
if (collectObject != null)
|
||||
collectObject.name = collector.CollectPath;
|
||||
|
@ -405,7 +405,7 @@ namespace YooAsset.Editor
|
|||
foldout.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
if (evt.newValue)
|
||||
RefreshFoldout(foldout, selectGrouper, collector);
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
else
|
||||
foldout.Clear();
|
||||
});
|
||||
|
@ -424,10 +424,10 @@ namespace YooAsset.Editor
|
|||
{
|
||||
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
objectField1.value.name = collector.CollectPath;
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGrouper, collector);
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -437,10 +437,10 @@ namespace YooAsset.Editor
|
|||
popupField0.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.CollectorType = StringUtility.NameToEnum<ECollectorType>(evt.newValue);
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGrouper, collector);
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -452,10 +452,10 @@ namespace YooAsset.Editor
|
|||
popupField1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.AddressRuleName = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGrouper, collector);
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -466,10 +466,10 @@ namespace YooAsset.Editor
|
|||
popupField2.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.PackRuleName = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGrouper, collector);
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -479,10 +479,10 @@ namespace YooAsset.Editor
|
|||
popupField3.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.FilterRuleName = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGrouper, collector);
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -492,17 +492,17 @@ namespace YooAsset.Editor
|
|||
textFiled1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.AssetTags = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
});
|
||||
}
|
||||
private void RefreshFoldout(Foldout foldout, AssetBundleGrouper grouper, AssetBundleCollector collector)
|
||||
private void RefreshFoldout(Foldout foldout, AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
// 清空旧元素
|
||||
foldout.Clear();
|
||||
|
||||
if (collector.IsValid() == false)
|
||||
{
|
||||
Debug.LogWarning($"The collector is invalid : {collector.CollectPath} in grouper : {grouper.GrouperName}");
|
||||
Debug.LogWarning($"The collector is invalid : {collector.CollectPath} in group : {group.GroupName}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -512,7 +512,7 @@ namespace YooAsset.Editor
|
|||
|
||||
try
|
||||
{
|
||||
collectAssetInfos = collector.GetAllCollectAssets(grouper);
|
||||
collectAssetInfos = collector.GetAllCollectAssets(group);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
|
@ -530,8 +530,8 @@ namespace YooAsset.Editor
|
|||
string showInfo = collectAssetInfo.AssetPath;
|
||||
if (_enableAddressableToogle.value)
|
||||
{
|
||||
IAddressRule instance = AssetBundleGrouperSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
||||
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, grouper.GrouperName);
|
||||
IAddressRule instance = AssetBundleCollectorSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
||||
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName);
|
||||
string addressValue = instance.GetAssetAddress(ruleData);
|
||||
showInfo = $"[{addressValue}] {showInfo}";
|
||||
}
|
||||
|
@ -548,21 +548,21 @@ namespace YooAsset.Editor
|
|||
}
|
||||
private void AddCollectorBtn_clicked()
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper == null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
|
||||
AssetBundleGrouperSettingData.CreateCollector(selectGrouper, string.Empty);
|
||||
AssetBundleCollectorSettingData.CreateCollector(selectGroup, string.Empty);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void RemoveCollectorBtn_clicked(AssetBundleCollector selectCollector)
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper == null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
if (selectCollector == null)
|
||||
return;
|
||||
AssetBundleGrouperSettingData.RemoveCollector(selectGrouper, selectCollector);
|
||||
AssetBundleCollectorSettingData.RemoveCollector(selectGroup, selectCollector);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
</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;">
|
||||
<ui:ListView focusable="true" name="GrouperListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="GrouperAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
|
||||
<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:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
|
@ -17,10 +17,10 @@
|
|||
<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="GrouperContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:TextField picking-mode="Ignore" label="Grouper Name" name="GrouperName" />
|
||||
<ui:TextField picking-mode="Ignore" label="Grouper Desc" name="GrouperDesc" />
|
||||
<ui:TextField picking-mode="Ignore" label="Grouper Asset Tags" name="GrouperAssetTags" />
|
||||
<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: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 Asset Tags" name="GroupAssetTags" />
|
||||
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
||||
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
|
@ -16,12 +16,12 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 以组名+文件名为定位地址
|
||||
/// </summary>
|
||||
public class AddressByGrouperAndFileName : IAddressRule
|
||||
public class AddressByGroupAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
return $"{data.GrouperName}_{fileName}";
|
||||
return $"{data.GroupName}_{fileName}";
|
||||
}
|
||||
}
|
||||
|
|
@ -78,11 +78,11 @@ namespace YooAsset.Editor
|
|||
/// 以分组名称作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
public class PackGrouper : IPackRule
|
||||
public class PackGroup : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
{
|
||||
return data.GrouperName;
|
||||
return data.GroupName;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,13 +5,13 @@ namespace YooAsset.Editor
|
|||
{
|
||||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GrouperName;
|
||||
public string GroupName;
|
||||
|
||||
public AddressRuleData(string assetPath, string collectPath, string grouperName)
|
||||
public AddressRuleData(string assetPath, string collectPath, string groupName)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GrouperName = grouperName;
|
||||
GroupName = groupName;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,19 +5,19 @@ namespace YooAsset.Editor
|
|||
{
|
||||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GrouperName;
|
||||
public string GroupName;
|
||||
|
||||
public PackRuleData(string assetPath)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = string.Empty;
|
||||
GrouperName = string.Empty;
|
||||
GroupName = string.Empty;
|
||||
}
|
||||
public PackRuleData(string assetPath, string collectPath, string grouperName)
|
||||
public PackRuleData(string assetPath, string collectPath, string groupName)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GrouperName = grouperName;
|
||||
GroupName = groupName;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 停靠窗口类型集合
|
||||
/// </summary>
|
||||
public static readonly Type[] DockedWindowTypes = { typeof(AssetBundleBuilderWindow), typeof(AssetBundleGrouperWindow), typeof(AssetBundleDebuggerWindow), typeof(AssetBundleReporterWindow)};
|
||||
public static readonly Type[] DockedWindowTypes = { typeof(AssetBundleBuilderWindow), typeof(AssetBundleCollectorWindow), typeof(AssetBundleDebuggerWindow), typeof(AssetBundleReporterWindow)};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace YooAsset.Editor
|
|||
List<string> allAssets = new List<string>(1000);
|
||||
|
||||
// 获取所有打包的资源
|
||||
List<CollectAssetInfo> allCollectInfos = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
||||
List<CollectAssetInfo> allCollectInfos = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets();
|
||||
List<string> collectAssets = allCollectInfos.Select(t => t.AssetPath).ToList();
|
||||
foreach (var assetPath in collectAssets)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DependAssetBundleGrouper
|
||||
internal class DependAssetBundleGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// 依赖的资源包加载器列表
|
||||
|
@ -12,7 +12,7 @@ namespace YooAsset
|
|||
private readonly List<AssetBundleLoaderBase> _dependBundles;
|
||||
|
||||
|
||||
public DependAssetBundleGrouper(string assetPath)
|
||||
public DependAssetBundleGroup(string assetPath)
|
||||
{
|
||||
_dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetPath);
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ namespace YooAsset
|
|||
internal abstract class BundledProvider : ProviderBase
|
||||
{
|
||||
protected AssetBundleLoaderBase OwnerBundle { private set; get; }
|
||||
protected DependAssetBundleGrouper DependBundles { private set; get; }
|
||||
protected DependAssetBundleGroup DependBundles { private set; get; }
|
||||
|
||||
public BundledProvider(string assetPath, System.Type assetType) : base(assetPath, assetType)
|
||||
{
|
||||
OwnerBundle = AssetSystem.CreateOwnerAssetBundleLoader(assetPath);
|
||||
OwnerBundle.Reference();
|
||||
OwnerBundle.AddProvider(this);
|
||||
DependBundles = new DependAssetBundleGrouper(assetPath);
|
||||
DependBundles = new DependAssetBundleGroup(assetPath);
|
||||
DependBundles.Reference();
|
||||
}
|
||||
public override void Destroy()
|
||||
|
|
Loading…
Reference in New Issue