using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor;
namespace YooAsset.Editor
{
[Serializable]
public class AssetBundleGrouper
{
///
/// 分组名称
///
public string GrouperName = string.Empty;
///
/// 分组描述
///
public string GrouperDesc = string.Empty;
///
/// 资源分类标签
///
public string AssetTags = string.Empty;
///
/// 分组的收集器列表
///
public List Collectors = new List();
///
/// 检测配置错误
///
public void CheckConfigError()
{
foreach (var collector in Collectors)
{
collector.CheckConfigError();
}
}
///
/// 获取打包收集的资源文件
///
public List GetAllCollectAssets()
{
Dictionary result = new Dictionary(10000);
// 收集打包资源
foreach (var collector in Collectors)
{
var temper = collector.GetAllCollectAssets(this);
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 : {GrouperName}");
}
}
// 检测可寻址地址是否重复
if (AssetBundleGrouperSettingData.Setting.EnableAddressable)
{
HashSet adressTemper = new HashSet();
foreach (var collectInfoPair in result)
{
if (collectInfoPair.Value.CollectorType == ECollectorType.MainCollector)
{
string address = collectInfoPair.Value.Address;
if (adressTemper.Contains(address) == false)
adressTemper.Add(address);
else
throw new Exception($"The address is existed : {address} in grouper : {GrouperName}");
}
}
}
// 返回列表
return result.Values.ToList();
}
}
}