52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
|
|
namespace YooAsset.Editor
|
|
{
|
|
public class TaskGetBuildMap : IBuildTask
|
|
{
|
|
void IBuildTask.Run(BuildContext context)
|
|
{
|
|
var buildMapContext = BuildMapHelper.SetupBuildMap();
|
|
context.SetContextObject(buildMapContext);
|
|
|
|
// 检测构建结果
|
|
CheckBuildMapContent(buildMapContext);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检测构建结果
|
|
/// </summary>
|
|
private void CheckBuildMapContent(BuildMapContext buildMapContext)
|
|
{
|
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
|
{
|
|
// 注意:原生文件资源包只能包含一个原生文件
|
|
bool isRawFile = bundleInfo.IsRawFile;
|
|
if (isRawFile)
|
|
{
|
|
if (bundleInfo.BuildinAssets.Count != 1)
|
|
throw new Exception("The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
|
continue;
|
|
}
|
|
|
|
// 注意:原生文件不能被其它资源文件依赖
|
|
foreach (var assetInfo in bundleInfo.BuildinAssets)
|
|
{
|
|
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}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |