
原理:bundle的依赖关系构建一个二维的矩阵图,如果对角线相互依赖(用1标记)则表示循环依赖。
using PlasticGui;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class DependProfiler
{
[MenuItem("Tools/CircleBundleDepend")]
static void Depend() {
string path = Application.streamingAssetsPath +"/StreamingAssets";
AssetBundleManifest manifest = BundleGroupEditor.ParseManifest(path);
var bundles = manifest.GetAllAssetBundles();
//bundle的依赖矩阵,如果对角值为1表示循环依赖
string[,] bundleMatrix = new string[bundles.Length+1, bundles.Length+1];
//添加表头
for (int i = 1; i < bundleMatrix.GetLength(0); i++)
{
var bundle = bundles[i-1];
bundleMatrix[i, 0] = bundle;
for(int j=1; j< bundleMatrix.GetLength(1); j++)

文章介绍了如何使用Unity中的AssetBundleManifest来构建依赖关系矩阵,通过检查对角线元素判断是否存在循环依赖,并在编辑器中显示结果。
最低0.47元/天 解锁文章
1159

被折叠的 条评论
为什么被折叠?



