Пример #1
0
        /// <summary>
        /// 冗余资源被反复引用的次数
        /// </summary>
        /// <param name="bundle"></param>
        /// <param name="resType"></param>
        /// <returns></returns>
        private int getAssetDedundancyCount(EditorBundleBean bundle, string resType)
        {
            int count = 0;
            List <ResoucresBean> resList = bundle.GetAllAssets();

            foreach (ResoucresBean res in resList)
            {
                if (resType == res.ResourceType && res.IncludeBundles.Count > 1)
                {
                    count++;
                }
            }
            return(count);
        }
Пример #2
0
        private void drawShaderAssets()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Shader名称", GUILayout.Width(200));
            GUILayout.Label("AB数量", GUILayout.Width(80));
            GUILayout.Label("所属AssetBundle");
            GUILayout.Label("详情", GUILayout.Width(100));
            GUILayout.EndHorizontal();

            GUILayoutHelper.DrawSeparator();

            scrollPos = GUILayout.BeginScrollView(scrollPos);
            List <ResoucresBean> resList = curBundle.GetAllAssets(EResoucresTypes.ShaderType);
            int index = 0;

            foreach (ResoucresBean res in resList)
            {
                if (string.IsNullOrEmpty(searchFilter) || res.Name.Contains(searchFilter))
                {
                    drawShaderRowAsset(res, index++);
                }
            }
            GUILayout.EndScrollView();
        }
Пример #3
0
        public void SetCurrentBundle(EditorBundleBean bundle)
        {
            curTabIndex    = 0;
            this.curBundle = bundle;
            resList        = bundle.GetAllAssets();
            resList.Sort((x, y) => x.IncludeBundles.Count.CompareTo(y.IncludeBundles.Count) * -1);

            foreach (ResoucresBean res in resList)
            {
                res.LoadRawAsset();
            }

            string title = string.Format("<color=white>[AssetBundle]<color=green>{0}</color></color>", curBundle.BundleName);

            ABMainChecker.MainChecker.SetCurrentView(ABMainChecker.EView.BundleDetailView, title);
        }
Пример #4
0
        private void loadAssetBundle(EditorBundleBean bundle)
        {
            loadIndex++;
            EditorUtility.DisplayProgressBar("分析中", "分析AssetBundle资源...", loadIndex / loadCount);

            string manifest = string.Concat(bundle.BundlePath, ".manifest");

            if (!File.Exists(manifest))
            {
                Debug.LogWarning("Cant find manifest ! " + manifest + "[" + bundle.BundleName + "]");
                return;
            }

            manifest = File.ReadAllText(manifest);
            string[] manifestInfoArr = manifest.Split('\n');

            //查找包含资源
            string[]             bundInfo  = getBundleInfo(manifestInfoArr, "Assets:");
            List <ResoucresBean> allAssets = bundle.GetAllAssets();

            ABMainChecker mainCheck = ABMainChecker.MainChecker;

            foreach (string assetPath in bundInfo)
            {
                //string assetName = Path.GetFileName(assetPath);
                ResoucresBean rb = null;
                if (!mainCheck.ResourceDic.TryGetValue(assetPath, out rb))
                {
                    rb = new ResoucresBean(assetPath);
                    mainCheck.ResourceDic[assetPath] = rb;
                }

                if (!rb.IncludeBundles.Contains(bundle))
                {
                    rb.IncludeBundles.Add(bundle);
                }

                allAssets.Add(rb);
            }

            //查找依赖
            bundInfo = getBundleInfo(manifestInfoArr, "Dependencies:");
            Dictionary <string, EditorBundleBean> bundles = ABMainChecker.MainChecker.BundleList;
            List <EditorBundleBean> depBundles            = bundle.GetAllDependencies();

            foreach (string curAssetPath in bundInfo)
            {
                EditorBundleBean depBundle = null;
                string           assetPath = GetRealBundlePath(curAssetPath);
                if (!bundles.TryGetValue(assetPath, out depBundle))
                {
                    depBundle          = new EditorBundleBean(assetPath);
                    bundles[assetPath] = depBundle;
                    loadAssetBundle(depBundle);
                }

                //依赖记录
                if (!depBundles.Contains(depBundle))
                {
                    depBundles.Add(depBundle);
                }

                //被依赖
                List <EditorBundleBean> beDepBundles = depBundle.GetBedependencies();
                if (!beDepBundles.Contains(bundle))
                {
                    beDepBundles.Add(bundle);
                }
            }
        }