Files
YooAsset/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs

54 lines
1.4 KiB
C#
Raw Normal View History

2022-03-01 10:44:12 +08:00
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace YooAsset.Editor
{
[TaskAttribute("获取资源构建内容")]
2022-03-01 10:44:12 +08:00
public class TaskGetBuildMap : IBuildTask
{
void IBuildTask.Run(BuildContext context)
{
var buildMapContext = BuildMapCreater.CreateBuildMap();
2022-03-01 10:44:12 +08:00
context.SetContextObject(buildMapContext);
BuildRunner.Log("构建内容准备完毕!");
2022-03-01 10:44:12 +08:00
// 检测构建结果
CheckBuildMapContent(buildMapContext);
}
/// <summary>
/// 检测构建结果
/// </summary>
private void CheckBuildMapContent(BuildMapContext buildMapContext)
{
2022-03-16 22:25:55 +08:00
foreach (var bundleInfo in buildMapContext.BundleInfos)
2022-03-01 10:44:12 +08:00
{
// 注意:原生文件资源包只能包含一个原生文件
bool isRawFile = bundleInfo.IsRawFile;
if (isRawFile)
{
2022-03-17 21:52:08 +08:00
if (bundleInfo.BuildinAssets.Count != 1)
throw new Exception($"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
2022-03-01 10:44:12 +08:00
continue;
}
// 注意:原生文件不能被其它资源文件依赖
2022-03-17 21:52:08 +08:00
foreach (var assetInfo in bundleInfo.BuildinAssets)
2022-03-01 10:44:12 +08:00
{
if (assetInfo.AllDependAssetInfos != null)
{
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
{
if (dependAssetInfo.IsRawAsset)
throw new Exception($"{assetInfo.AssetPath} can not depend raw asset : {dependAssetInfo.AssetPath}");
}
}
}
}
}
}
}