mirror of https://github.com/tuyoogame/YooAsset
84 lines
2.0 KiB
C#
84 lines
2.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace YooAsset.Editor
|
|
{
|
|
public class AssetBundleCollectorSetting : ScriptableObject
|
|
{
|
|
/// <summary>
|
|
/// 是否启用可寻址资源定位
|
|
/// </summary>
|
|
public bool EnableAddressable = false;
|
|
|
|
/// <summary>
|
|
/// 自动收集着色器
|
|
/// </summary>
|
|
public bool AutoCollectShaders = true;
|
|
|
|
/// <summary>
|
|
/// 自动收集的着色器资源包名称
|
|
/// </summary>
|
|
public string ShadersBundleName = "myshaders";
|
|
|
|
/// <summary>
|
|
/// 分组列表
|
|
/// </summary>
|
|
public List<AssetBundleCollectorGroup> Groups = new List<AssetBundleCollectorGroup>();
|
|
|
|
|
|
/// <summary>
|
|
/// 检测配置错误
|
|
/// </summary>
|
|
public void CheckConfigError()
|
|
{
|
|
foreach (var group in Groups)
|
|
{
|
|
group.CheckConfigError();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取打包收集的资源文件
|
|
/// </summary>
|
|
public List<CollectAssetInfo> GetAllCollectAssets()
|
|
{
|
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
|
|
|
// 收集打包资源
|
|
foreach (var group in Groups)
|
|
{
|
|
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 group setting.");
|
|
}
|
|
}
|
|
|
|
// 检测可寻址地址是否重复
|
|
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} in group setting.");
|
|
}
|
|
}
|
|
}
|
|
|
|
// 返回列表
|
|
return result.Values.ToList();
|
|
}
|
|
}
|
|
} |