Update AssetBundleBuilder

This commit is contained in:
hevinci
2022-03-16 17:35:21 +08:00
parent 299f770692
commit a91f1bd020
8 changed files with 100 additions and 153 deletions

View File

@@ -13,17 +13,12 @@ namespace YooAsset.Editor
/// <summary>
/// 资源路径
/// </summary>
public string AssetPath { private set; get; }
public string AssetPath;
/// <summary>
/// 资源包标签
/// 资源包完整名称
/// </summary>
public string BundleLabel { private set; get; }
/// <summary>
/// 资源包文件格式
/// </summary>
public string BundleVariant { private set; get; }
public string BundleName;
/// <summary>
/// 是否为原生资源
@@ -46,10 +41,10 @@ namespace YooAsset.Editor
public int DependCount = 0;
/// <summary>
/// 依赖的所有资源信息
/// 注意:包括零依赖资源(零依赖资源资源包名无效)
/// 依赖的所有资源
/// 注意:包括零依赖资源和冗余资源资源包名无效)
/// </summary>
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; } = null;
public List<BuildAssetInfo> AllDependAssetInfos;
public BuildAssetInfo(string assetPath)
@@ -73,11 +68,10 @@ namespace YooAsset.Editor
/// </summary>
public void SetBundleLabelAndVariant(string bundleLabel, string bundleVariant)
{
if (string.IsNullOrEmpty(BundleLabel) == false || string.IsNullOrEmpty(BundleVariant) == false)
if (string.IsNullOrEmpty(BundleName) == false)
throw new System.Exception("Should never get here !");
BundleLabel = bundleLabel;
BundleVariant = bundleVariant;
BundleName = AssetBundleBuilderHelper.MakeBundleName(bundleLabel, bundleVariant);
}
/// <summary>
@@ -95,25 +89,14 @@ namespace YooAsset.Editor
}
/// <summary>
/// 获取资源包的完整名称
/// 资源包名是否有效
/// </summary>
public string GetBundleName()
public bool BundleNameIsValid()
{
if (string.IsNullOrEmpty(BundleLabel) || string.IsNullOrEmpty(BundleVariant))
throw new System.ArgumentNullException();
return AssetBundleBuilderHelper.MakeBundleName(BundleLabel, BundleVariant);
}
/// <summary>
/// 检测资源包名是否有效
/// </summary>
public bool CheckBundleNameValid()
{
if (string.IsNullOrEmpty(BundleLabel) == false && string.IsNullOrEmpty(BundleVariant) == false)
return true;
else
if (string.IsNullOrEmpty(BundleName))
return false;
else
return true;
}
}
}

View File

@@ -15,22 +15,12 @@ namespace YooAsset.Editor
/// <summary>
/// 资源包完整名称
/// </summary>
public string BundleName { private set; get; }
/// <summary>
/// 资源包标签名
/// </summary>
public string BundleLabel { private set; get; }
/// <summary>
/// 资源包文件格式
/// </summary>
public string BundleVariant { private set; get; }
public string BundleName;
/// <summary>
/// 包含的资源列表
/// </summary>
public readonly List<BuildAssetInfo> Assets = new List<BuildAssetInfo>();
public List<BuildAssetInfo> Assets = new List<BuildAssetInfo>();
/// <summary>
/// 是否为原生文件
@@ -49,11 +39,9 @@ namespace YooAsset.Editor
}
public BuildBundleInfo(string bundleLabel, string bundleVariant)
public BuildBundleInfo(string bundleName)
{
BundleLabel = bundleLabel;
BundleVariant = bundleVariant;
BundleName = AssetBundleBuilderHelper.MakeBundleName(bundleLabel, bundleVariant);
BundleName = bundleName;
}
/// <summary>
@@ -110,14 +98,6 @@ namespace YooAsset.Editor
return result.ToArray();
}
/// <summary>
/// 获取主动收集的资源路径列表
/// </summary>
public string[] GetCollectAssetPaths()
{
return Assets.Where(t => t.IsCollectAsset).Select(t => t.AssetPath).ToArray();
}
/// <summary>
/// 获取构建的资源路径列表
/// </summary>

View File

@@ -1,10 +1,8 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace YooAsset
namespace YooAsset.Editor
{
/// <summary>
/// 构建报告
@@ -12,6 +10,40 @@ namespace YooAsset
[Serializable]
public class BuildReport
{
/// <summary>
/// 资源包列表
/// </summary>
public readonly List<BuildBundleInfo> BundleInfos = new List<BuildBundleInfo>(1000);
/// <summary>
/// 冗余的资源列表
/// </summary>
public readonly List<string> RedundancyList = new List<string>(1000);
/// <summary>
/// 检测是否包含BundleName
/// </summary>
public bool IsContainsBundle(string bundleFullName)
{
return TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo);
}
/// <summary>
/// 尝试获取资源包类,如果没有返回空
/// </summary>
public bool TryGetBundleInfo(string bundleFullName, out BuildBundleInfo result)
{
foreach (var bundleInfo in BundleInfos)
{
if (bundleInfo.BundleName == bundleFullName)
{
result = bundleInfo;
return true;
}
}
result = null;
return false;
}
}
}