Example #1
0
        /// <summary>
        /// 绘制每条资源信息
        /// </summary>
        /// <param name="res"></param>
        /// <param name="indexRow"></param>
        private void drawRowAsset(ResoucresBean res, int 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;

            GUI.color = selectAsset == res.Name ? Color.green : Color.white;
            if (GUILayout.Button(res.Name, EditorStyles.label, GUILayout.Width(200)))
            {
                selectAsset = res.Name;
            }

            GUILayout.Label(res.ResourceType, GUILayout.Width(100));

            //具体的ab名称
            int column = Mathf.Max(1, (int)((ABMainChecker.MainChecker.Width - 380) / 150));

            if (res.IncludeBundles.Count > 1)
            {
                drawBundleGrid(curBundle, res, column);
            }
            GUI.color = Color.white;

            GUILayout.EndHorizontal();
        }
Example #2
0
        public void SetResoucre(ResoucresBean res)
        {
            curRes       = res;
            searchFilter = "";
            GUIUtility.keyboardControl = 0;

            string title = string.Format("<color=white>[{1}]<color=green>{0}</color></color>", curRes.Name, curRes.ResourceType);

            ABMainChecker.MainChecker.SetCurrentView(ABMainChecker.EView.AssetDistributeView, title);
        }
Example #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();
        }
Example #4
0
        private void drawShaderRowAsset(ResoucresBean res, int 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;

            GUI.color = selectAsset == res.Name ? Color.green : Color.white;
            if (GUILayout.Button(res.Name, EditorStyles.label, GUILayout.Width(200)))
            {
                selectAsset = res.Name;
            }

            GUILayout.Label(res.IncludeBundles.Count.ToString(), GUILayout.Width(80));

            //具体的ab名称
            if (res.IncludeBundles.Count > 1)
            {
                drawBundleGrid(curBundle, res, 4);
            }
            GUI.color = Color.white;

            GUILayout.EndHorizontal();
        }
Example #5
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);
                }
            }
        }
Example #6
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();
        }
Example #7
0
        /// <summary>
        /// 检测依赖资源
        /// </summary>
        public void CheckDependencies()
        {
            mainObjs = new [] { AssetDatabase.LoadAssetAtPath <Object>(this.AssetPath) };
            Object[] depArr = EditorUtility.CollectDependencies(mainObjs);

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

            foreach (Object depAsset in depArr)
            {
                ResoucresBean rb           = null;
                string        depAssetPath = AssetDatabase.GetAssetPath(depAsset);
                //Library asset
                if (BuiltinChecker.IsLibraryRes(depAssetPath))
                {
                    continue;
                }

                if (BuiltinChecker.IsExtraRes(depAssetPath))
                {
                    depAssetPath = BuiltinChecker.GetBuiltinAssetPath(depAsset);
                    if (!resDic.TryGetValue(depAssetPath, out rb))
                    {
                        rb = new ResoucresBean(depAssetPath);
                        rb.IsBuiltinExa      = true;
                        resDic[depAssetPath] = rb;
                    }
                    //如果是内置资源,将会重复打包到所属bundle内
                    foreach (EditorBundleBean bundle in this.IncludeBundles)
                    {
                        if (rb.IncludeBundles.Contains(bundle))
                        {
                            continue;
                        }
                        rb.IncludeBundles.Add(bundle);
                    }

                    //bundle包含
                    foreach (EditorBundleBean bundle in IncludeBundles)
                    {
                        List <ResoucresBean> allAsset = bundle.GetAllAssets();
                        if (allAsset.Contains(rb))
                        {
                            continue;
                        }
                        allAsset.Add(rb);
                    }
                }
                else
                {
                    string depAssetName = Path.GetFileName(depAssetPath);
                    if (depAssetName == Name)
                    {
                        continue;
                    }

                    //排除不打包的文件,比如.cs
                    string suffix = Path.GetExtension(depAssetPath);
                    if (ABMainChecker.ExcludeFiles.Contains(suffix))
                    {
                        continue;
                    }

                    if (!resDic.TryGetValue(depAssetPath, out rb))
                    {
                        rb                   = new ResoucresBean(depAssetPath);
                        rb.IsMissing         = true;
                        resDic[depAssetPath] = rb;

                        ABMainChecker.MainChecker.MissingRes.Add(rb);
                    }
                }

                Dependencies[depAssetPath] = rb;
            }
        }