Files
YooAsset/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs

121 lines
2.5 KiB
C#
Raw Normal View History

2022-03-16 11:33:45 +08:00
using System;
using System.Collections;
2022-03-01 10:44:12 +08:00
using System.Collections.Generic;
namespace YooAsset.Editor
{
public class BuildAssetInfo
{
2022-04-02 15:12:08 +08:00
/// <summary>
/// 资源包名称
/// </summary>
public string BundleName { private set; get; }
2022-03-01 10:44:12 +08:00
/// <summary>
/// 资源路径
/// </summary>
2022-03-17 15:27:49 +08:00
public string AssetPath { private set; get; }
2022-03-01 10:44:12 +08:00
/// <summary>
2022-04-02 15:12:08 +08:00
/// 是否为原生资源
2022-03-01 10:44:12 +08:00
/// </summary>
2022-04-02 15:12:08 +08:00
public bool IsRawAsset { private set; get; }
2022-03-01 10:44:12 +08:00
/// <summary>
2022-04-02 15:12:08 +08:00
/// 不写入资源列表
2022-03-01 10:44:12 +08:00
/// </summary>
2022-04-02 15:12:08 +08:00
public bool NotWriteToAssetList { private set; get; }
2022-03-01 10:44:12 +08:00
/// <summary>
/// 是否为主动收集资源
/// </summary>
2022-04-02 15:12:08 +08:00
public bool IsCollectAsset { private set; get; }
2022-03-01 10:44:12 +08:00
/// <summary>
2022-03-17 15:27:49 +08:00
/// 被依赖次数
2022-03-01 10:44:12 +08:00
/// </summary>
2022-03-17 15:27:49 +08:00
public int DependCount = 0;
2022-03-01 10:44:12 +08:00
/// <summary>
2022-04-02 15:12:08 +08:00
/// 资源分类标签列表
2022-03-01 10:44:12 +08:00
/// </summary>
2022-03-17 15:27:49 +08:00
public readonly List<string> AssetTags = new List<string>();
2022-03-01 10:44:12 +08:00
/// <summary>
2022-03-16 17:35:21 +08:00
/// 依赖的所有资源
/// 注意:包括零依赖资源和冗余资源(资源包名无效)
2022-03-01 10:44:12 +08:00
/// </summary>
2022-03-17 15:27:49 +08:00
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
2022-03-01 10:44:12 +08:00
2022-04-02 15:12:08 +08:00
public BuildAssetInfo(string assetPath, bool isRawAsset, bool notWriteToAssetList)
{
AssetPath = assetPath;
IsRawAsset = isRawAsset;
NotWriteToAssetList = notWriteToAssetList;
IsCollectAsset = true;
}
2022-03-01 10:44:12 +08:00
public BuildAssetInfo(string assetPath)
{
AssetPath = assetPath;
2022-04-02 15:12:08 +08:00
IsRawAsset = false;
NotWriteToAssetList = true;
IsCollectAsset = false;
2022-03-01 10:44:12 +08:00
}
/// <summary>
/// 设置所有依赖的资源
/// </summary>
public void SetAllDependAssetInfos(List<BuildAssetInfo> dependAssetInfos)
{
if (AllDependAssetInfos != null)
throw new System.Exception("Should never get here !");
AllDependAssetInfos = dependAssetInfos;
}
/// <summary>
2022-04-02 15:12:08 +08:00
/// 设置资源包名称
2022-03-01 10:44:12 +08:00
/// </summary>
2022-04-02 15:12:08 +08:00
public void SetBundleName(string bundleName)
2022-03-01 10:44:12 +08:00
{
2022-03-16 17:35:21 +08:00
if (string.IsNullOrEmpty(BundleName) == false)
2022-03-01 10:44:12 +08:00
throw new System.Exception("Should never get here !");
2022-04-02 15:12:08 +08:00
BundleName = bundleName;
2022-03-01 10:44:12 +08:00
}
/// <summary>
2022-04-02 15:12:08 +08:00
/// 添加资源分类标签
2022-03-01 10:44:12 +08:00
/// </summary>
public void AddAssetTags(List<string> tags)
{
foreach (var tag in tags)
{
2022-03-17 15:27:49 +08:00
AddAssetTag(tag);
}
}
/// <summary>
2022-04-02 15:12:08 +08:00
/// 添加资源分类标签
2022-03-17 15:27:49 +08:00
/// </summary>
public void AddAssetTag(string tag)
{
if (AssetTags.Contains(tag) == false)
{
AssetTags.Add(tag);
2022-03-01 10:44:12 +08:00
}
}
/// <summary>
2022-04-02 15:12:08 +08:00
/// 资源包名称是否有效
2022-03-01 10:44:12 +08:00
/// </summary>
2022-03-16 17:35:21 +08:00
public bool BundleNameIsValid()
2022-03-01 10:44:12 +08:00
{
2022-03-16 17:35:21 +08:00
if (string.IsNullOrEmpty(BundleName))
2022-03-01 10:44:12 +08:00
return false;
2022-03-16 17:35:21 +08:00
else
return true;
2022-03-01 10:44:12 +08:00
}
}
}