示例#1
0
        private void drawRowRedundancyAsset(EditorBundleBean bundle)
        {
            indexRow++;
            GUI.backgroundColor = indexRow % 2 == 0 ? Color.white : new Color(0.8f, 0.8f, 0.8f);
            GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(25f));
            GUI.backgroundColor = Color.white;
            //名称
            GUILayout.Label(bundle.BundleName, GUILayout.MinWidth(300));
            //Mesh
            int count = getAssetDedundancyCount(bundle, EResoucresTypes.MeshType);

            GUILayout.Space(40);
            GUILayout.Label(count.ToString(), GUILayout.MinWidth(100));
            //material
            count = getAssetDedundancyCount(bundle, EResoucresTypes.MatrialType);
            GUILayout.Space(40);
            GUILayout.Label(count.ToString(), GUILayout.MinWidth(100));
            //Texture
            count = getAssetDedundancyCount(bundle, EResoucresTypes.TextureType);
            GUILayout.Space(40);
            GUILayout.Label(count.ToString(), GUILayout.MinWidth(100));
            //Shader
            count = getAssetDedundancyCount(bundle, EResoucresTypes.ShaderType);
            GUILayout.Space(40);
            GUILayout.Label(count.ToString(), GUILayout.MinWidth(100));
            //查询
            GUILayout.Space(25);
            if (GUILayout.Button("GO", GUILayout.Width(50), GUILayout.Height(25)))
            {
                ABMainChecker.MainChecker.DetailBundleView.SetCurrentBundle(bundle);
            }
            GUILayout.Space(25);
            GUILayout.EndHorizontal();
        }
示例#2
0
        private void drawRowBundle(EditorBundleBean bundle)
        {
            indexRow++;
            GUI.backgroundColor = indexRow % 2 == 0 ? Color.white : new Color(0.8f, 0.8f, 0.8f);
            GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
            GUI.backgroundColor = Color.white;
            //名称
            GUILayout.Label(bundle.BundleName, GUILayout.Width(200));
            //依赖数量
            List <EditorBundleBean> dependencies = bundle.GetAllDependencies();

            GUILayout.Label(dependencies.Count.ToString(), GUILayout.Width(80));
            //文件大小
            GUILayout.Label(bundle.FileSize >= 1024 ? string.Format("{0:F}MB", bundle.FileSize / 1024F) :
                            string.Format("{0}KB", bundle.FileSize), GUILayout.Width(80));
            //具体的ab名称
            GUILayout.BeginVertical();
            int column   = Mathf.Max(1, (int)((ABMainChecker.MainChecker.Width - 380) / 150));
            int endIndex = 0;

            for (int i = 0, maxCount = dependencies.Count; i < maxCount; i++)
            {
                EditorBundleBean depBundle = dependencies[i];
                if (i % column == 0)
                {
                    endIndex = i + column - 1;
                    GUILayout.BeginHorizontal();
                }
                if (GUILayout.Button(depBundle.BundleName, GUILayout.Width(150)))
                {
                    ABMainChecker.MainChecker.DetailBundleView.SetCurrentBundle(depBundle);
                }
                if (i == endIndex)
                {
                    endIndex = 0;
                    GUILayout.EndHorizontal();
                }
            }
            if (endIndex != 0)
            {
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            //查询
            GUILayout.Space(15);
            if (GUILayout.Button("GO", GUILayout.Width(50), GUILayout.Height(25)))
            {
                ABMainChecker.MainChecker.DetailBundleView.SetCurrentBundle(bundle);
            }
            GUILayout.Space(15);
            GUILayout.EndHorizontal();
        }
示例#3
0
        /// <summary>
        /// 绘制GriLayout布局的Bundle信息
        /// </summary>
        /// <param name="res"></param>
        /// <param name="column"></param>
        public static void drawBundleGrid(EditorBundleBean curBundle, ResoucresBean res, int column)
        {
            GUILayout.BeginVertical();
            int countIndex = 0;
            int endIndex   = 0;

            for (int i = 0, maxCount = res.IncludeBundles.Count; i < maxCount; i++)
            {
                EditorBundleBean depBundle = res.IncludeBundles[i];
                if (depBundle == curBundle)
                {
                    continue;
                }

                if (countIndex % column == 0)
                {
                    endIndex = countIndex + column - 1;
                    GUILayout.BeginHorizontal();
                }
                if (GUILayout.Button(depBundle.BundleName, GUILayout.Width(140)))
                {
                    ABMainChecker.MainChecker.DetailBundleView.SetCurrentBundle(depBundle);
                }
                if (countIndex == endIndex)
                {
                    endIndex = 0;
                    GUILayout.EndHorizontal();
                }
                countIndex++;
            }
            if (endIndex != 0)
            {
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            GUILayout.FlexibleSpace();

            GUILayout.BeginVertical();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.Space(15);
            if (GUILayout.Button("GO", GUILayout.Width(70), GUILayout.Height(25)))
            {
                ABMainChecker.MainChecker.AssetView.SetResoucre(res);
            }
            GUILayout.Space(15);
            GUILayout.EndHorizontal();
            GUILayout.Space(5);
            GUILayout.EndVertical();
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
0
        private void drawBundle(EditorBundleBean bundle)
        {
            indexRow++;
            GUI.backgroundColor = indexRow % 2 == 0 ? Color.white : new Color(0.8f, 0.8f, 0.8f);
            GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
            GUI.backgroundColor = Color.white;

//          名称
            GUILayout.Label(bundle.BundleName);

//          查询
            GUILayout.Space(15);
            if (GUILayout.Button("GO", GUILayout.Width(50), GUILayout.Height(25)))
            {
                ABMainChecker.MainChecker.DetailBundleView.SetCurrentBundle(bundle);
            }
            GUILayout.Space(15);
            GUILayout.EndHorizontal();
        }
示例#7
0
        /// <summary>
        /// 冗余的资源
        /// </summary>
        private void drawAllBundles()
        {
            EditorGUILayout.HelpBox(tipStr, MessageType.Info);
            //all assets
            NGUIEditorTools.DrawHeader("All AssetBundle");

            //Search
            GUILayout.BeginHorizontal();
            {
                searchFilter = EditorGUILayout.TextField("", searchFilter, "SearchTextField", GUILayout.Width(Screen.width - 20f));

                if (GUILayout.Button("", "SearchCancelButton", GUILayout.Width(18f)))
                {
                    searchFilter = "";
                    GUIUtility.keyboardControl = 0;
                }
            }
            GUILayout.EndHorizontal();

//            GUILayout.BeginHorizontal();
//            GUILayout.Toggle(false, "所属AssetBundle名称", "ButtonLeft");
//            //GUILayout.Toggle(false, "依赖数量", "ButtonMid", GUILayout.Width(80));
//            //GUILayout.Toggle(false, "所属AssetBundle文件", "ButtonMid");
//            GUILayout.Toggle(false, "详细", "ButtonRight", GUILayout.Width(100));
//            GUILayout.EndHorizontal();

            scrollPos = GUILayout.BeginScrollView(scrollPos, false, true);


            GUILayout.BeginVertical();
            int countIndex = 0;
            int endIndex   = 0;
            int column     = 4;
            int width      = (int)(ABMainChecker.MainChecker.Width - 50) / column;

            for (int i = 0, maxCount = curRes.IncludeBundles.Count; i < maxCount; i++)
            {
                EditorBundleBean bundle = curRes.IncludeBundles[i];

                if (countIndex % column == 0)
                {
                    endIndex = countIndex + column - 1;
                    GUILayout.BeginHorizontal();
                }

                if (GUILayout.Button(bundle.BundleName, GUILayout.Width(width)))
                {
                    ABMainChecker.MainChecker.DetailBundleView.SetCurrentBundle(bundle);
                }

                if (countIndex == endIndex)
                {
                    endIndex = 0;
                    GUILayout.EndHorizontal();
                }
                countIndex++;
            }
            if (endIndex != 0)
            {
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

//            foreach (EditorBundleBean bundle in curRes.IncludeBundles)
//            {
//                if(string.IsNullOrEmpty(searchFilter) || bundle.BundleName.Contains(searchFilter))
//                    drawBundle(bundle);
//            }
            GUILayout.EndScrollView();
        }
示例#8
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);
                }
            }
        }
示例#9
0
        /// <summary>
        /// 查找指定目录的Bundles
        /// </summary>
        private void findAllBundles()
        {
            string rootPath = CurFolderRoot;

            if (!Directory.Exists(rootPath))
            {
                return;
            }

            string[] fileArr = Directory.GetFiles(rootPath, "*" + ABMainChecker.AssetBundleSuffix, SearchOption.AllDirectories);
            //记录bundle路径,用于校验
            allBundleFiles.Clear();
            foreach (string abPath in fileArr)
            {
                allBundleFiles[Path.GetFileName(abPath)] = abPath;
            }

            ABMainChecker.MainChecker.Clear();

            Dictionary <string, EditorBundleBean> bundleDic = ABMainChecker.MainChecker.BundleList;

            EditorUtility.DisplayProgressBar("查找中", "正在查找文件...", 1.0f / fileArr.Length);
            loadCount = (float)fileArr.Length;
            loadIndex = 0;

            for (int i = 0, maxCount = fileArr.Length; i < maxCount; i++)
            {
                string assetPath = GetRealBundlePath(fileArr[i]);
                if (!bundleDic.ContainsKey(assetPath))
                {
                    EditorBundleBean bundleBean = new EditorBundleBean(assetPath);
                    bundleDic[assetPath] = bundleBean;
                    loadAssetBundle(bundleBean);
                }
            }


            Dictionary <string, ResoucresBean> resDic = ABMainChecker.MainChecker.ResourceDic;

            ResoucresBean[] resArr = new ResoucresBean[resDic.Count];
            resDic.Values.CopyTo(resArr, 0);

            redundancyDic.Clear();
            for (int i = 0, maxCount = resArr.Length; i < maxCount; i++)
            {
                EditorUtility.DisplayProgressBar("分析中", "检测依赖资源...", (float)i / maxCount);
                resArr[i].CheckDependencies();
            }

            //再检测冗余
            int   _i        = 0;
            float _maxCount = resDic.Count;

            foreach (ResoucresBean res in resDic.Values)
            {
                EditorUtility.DisplayProgressBar("分析中", "分析冗余...", _i / _maxCount);
                _i++;
                if (res.IncludeBundles.Count <= 1)
                {
                    continue;
                }

                foreach (EditorBundleBean bundle in res.IncludeBundles)
                {
                    redundancyDic[bundle.BundleName] = bundle;
                }
            }
            EditorUtility.ClearProgressBar();
        }
示例#10
0
 private int comparerAssetCount(EditorBundleBean x, EditorBundleBean y, string resType)
 {
     return(getAssetDedundancyCount(x, resType).CompareTo(getAssetDedundancyCount(y, resType)) * sortToggle);
 }