mirror of https://github.com/tuyoogame/YooAsset
parent
ae465a47a9
commit
67eeae31c7
|
@ -10,6 +10,7 @@ namespace YooAsset.Editor
|
|||
private string _mainBundleName;
|
||||
private string _shareBundleName;
|
||||
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
|
||||
private bool _isAddAssetTags = false;
|
||||
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
|
@ -37,10 +38,15 @@ namespace YooAsset.Editor
|
|||
public bool IsShaderAsset { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源分类标签列表
|
||||
/// 资源的分类标签
|
||||
/// </summary>
|
||||
public readonly List<string> AssetTags = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 资源包的分类标签
|
||||
/// </summary>
|
||||
public readonly List<string> BundleTags = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的所有资源
|
||||
/// 注意:包括零依赖资源和冗余资源(资源包名无效)
|
||||
|
@ -89,10 +95,15 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加资源分类标签
|
||||
/// 添加资源的分类标签
|
||||
/// 说明:原始定义的资源分类标签
|
||||
/// </summary>
|
||||
public void AddAssetTags(List<string> tags)
|
||||
{
|
||||
if (_isAddAssetTags)
|
||||
throw new Exception("Should never get here !");
|
||||
_isAddAssetTags = true;
|
||||
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
if (AssetTags.Contains(tag) == false)
|
||||
|
@ -102,6 +113,21 @@ namespace YooAsset.Editor
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加资源包的分类标签
|
||||
/// 说明:传染算法统计到的分类标签
|
||||
/// </summary>
|
||||
public void AddBundleTags(List<string> tags)
|
||||
{
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
if (BundleTags.Contains(tag) == false)
|
||||
{
|
||||
BundleTags.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名是否存在
|
||||
/// </summary>
|
||||
|
|
|
@ -68,14 +68,14 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源标签列表
|
||||
/// 获取资源包的分类标签列表
|
||||
/// </summary>
|
||||
public string[] GetAssetTags()
|
||||
public string[] GetBundleTags()
|
||||
{
|
||||
List<string> result = new List<string>(BuildinAssets.Count);
|
||||
foreach (var assetInfo in BuildinAssets)
|
||||
{
|
||||
foreach (var assetTag in assetInfo.AssetTags)
|
||||
foreach (var assetTag in assetInfo.BundleTags)
|
||||
{
|
||||
if (result.Contains(assetTag) == false)
|
||||
result.Add(assetTag);
|
||||
|
|
|
@ -55,13 +55,13 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取AssetBundle内包含的标记列表
|
||||
/// 获取资源包的分类标签列表
|
||||
/// </summary>
|
||||
public string[] GetAssetTags(string bundleName)
|
||||
public string[] GetBundleTags(string bundleName)
|
||||
{
|
||||
if (TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
||||
{
|
||||
return bundleInfo.GetAssetTags();
|
||||
return bundleInfo.GetBundleTags();
|
||||
}
|
||||
throw new Exception($"Not found {nameof(BuildBundleInfo)} : {bundleName}");
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace YooAsset.Editor
|
|||
// 1. 检测配置合法性
|
||||
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
||||
|
||||
// 2. 获取所有主动收集的资源
|
||||
// 2. 获取所有收集器收集的资源
|
||||
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets(buildMode);
|
||||
|
||||
// 3. 剔除未被引用的依赖资源
|
||||
|
@ -36,13 +36,15 @@ namespace YooAsset.Editor
|
|||
allCollectAssets.Remove(removeValue);
|
||||
}
|
||||
|
||||
// 4. 录入主动收集的资源
|
||||
// 4. 录入所有收集器收集的资源
|
||||
foreach (var collectAssetInfo in allCollectAssets)
|
||||
{
|
||||
if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
|
||||
{
|
||||
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset);
|
||||
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName,
|
||||
collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset);
|
||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
||||
buildAssetDic.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
||||
}
|
||||
else
|
||||
|
@ -58,13 +60,13 @@ namespace YooAsset.Editor
|
|||
{
|
||||
if (buildAssetDic.ContainsKey(dependAssetPath))
|
||||
{
|
||||
buildAssetDic[dependAssetPath].AddAssetTags(collectAssetInfo.AssetTags);
|
||||
buildAssetDic[dependAssetPath].AddBundleTags(collectAssetInfo.AssetTags);
|
||||
buildAssetDic[dependAssetPath].AddReferenceBundleName(collectAssetInfo.BundleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
var buildAssetInfo = new BuildAssetInfo(ECollectorType.None, dependAssetPath);
|
||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
||||
buildAssetInfo.AddReferenceBundleName(collectAssetInfo.BundleName);
|
||||
buildAssetDic.Add(dependAssetPath, buildAssetInfo);
|
||||
}
|
||||
|
@ -92,7 +94,7 @@ namespace YooAsset.Editor
|
|||
pair.Value.CalculateFullBundleName();
|
||||
}
|
||||
|
||||
// 8. 移除未参与构建的资源
|
||||
// 8. 移除不参与构建的资源
|
||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,11 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public string AssetGUID;
|
||||
|
||||
/// <summary>
|
||||
/// 资源的分类标签
|
||||
/// </summary>
|
||||
public string[] AssetTags;
|
||||
|
||||
/// <summary>
|
||||
/// 所属资源包名称
|
||||
/// </summary>
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace YooAsset.Editor
|
|||
string hash = GetFileHash(filePath, standardBuild);
|
||||
string crc32 = GetFileCRC(filePath, standardBuild);
|
||||
long size = GetFileSize(filePath, standardBuild);
|
||||
string[] tags = buildMapContext.GetAssetTags(bundleName);
|
||||
string[] tags = buildMapContext.GetBundleTags(bundleName);
|
||||
bool isEncrypted = encryptionContext.IsEncryptFile(bundleName);
|
||||
bool isBuildin = IsBuildinBundle(tags, buildinTags);
|
||||
bool isRawFile = bundleInfo.IsRawFile;
|
||||
|
@ -141,6 +141,7 @@ namespace YooAsset.Editor
|
|||
else
|
||||
patchAsset.Address = string.Empty;
|
||||
patchAsset.AssetPath = assetInfo.AssetPath;
|
||||
patchAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||
patchAsset.BundleID = GetAssetBundleID(assetInfo.GetBundleName(), patchManifest);
|
||||
patchAsset.DependIDs = GetAssetBundleDependIDs(patchAsset.BundleID, assetInfo, patchManifest);
|
||||
result.Add(patchAsset);
|
||||
|
|
|
@ -75,6 +75,7 @@ namespace YooAsset.Editor
|
|||
ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
|
||||
reportAssetInfo.Address = patchAsset.Address;
|
||||
reportAssetInfo.AssetPath = patchAsset.AssetPath;
|
||||
reportAssetInfo.AssetTags = patchAsset.AssetTags;
|
||||
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(patchAsset.AssetPath);
|
||||
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
||||
reportAssetInfo.MainBundleSize = mainBundle.SizeBytes;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
|
@ -15,6 +16,11 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public string AssetPath;
|
||||
|
||||
/// <summary>
|
||||
/// 资源的分类标签
|
||||
/// </summary>
|
||||
public string[] AssetTags;
|
||||
|
||||
/// <summary>
|
||||
/// 所属资源包ID
|
||||
/// </summary>
|
||||
|
@ -24,5 +30,24 @@ namespace YooAsset
|
|||
/// 依赖的资源包ID列表
|
||||
/// </summary>
|
||||
public int[] DependIDs;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含Tag
|
||||
/// </summary>
|
||||
public bool HasTag(string[] tags)
|
||||
{
|
||||
if (tags == null || tags.Length == 0)
|
||||
return false;
|
||||
if (AssetTags == null || AssetTags.Length == 0)
|
||||
return false;
|
||||
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
if (AssetTags.Contains(tag))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ namespace YooAsset
|
|||
public long SizeBytes;
|
||||
|
||||
/// <summary>
|
||||
/// Tags
|
||||
/// 资源包的分类标签
|
||||
/// </summary>
|
||||
public string[] Tags;
|
||||
|
||||
|
|
Loading…
Reference in New Issue