Exemple #1
0
    static void CheckAssetBundleCross()
    {
        StringBuilder builder = new StringBuilder();

        string[] names = AssetDatabase.GetAllAssetBundleNames();
        foreach (string name in names)
        {
            string[] dependencies = AssetDatabase.GetAssetBundleDependencies(name, true);
            foreach (string dependency in dependencies)
            {
                string[] dependencies2 = AssetDatabase.GetAssetBundleDependencies(dependency, true);
                foreach (string dependency2 in dependencies2)
                {
                    if (string.Equals(name, dependency2))
                    {
                        builder.AppendFormat("{0} <-> {1}\n", name, dependency);
                    }
                }
            }
        }

        string txt = builder.ToString();

        if (!string.IsNullOrEmpty(txt))
        {
            Debug.LogFormat("以下ab出现交叉依赖:\n{0}", txt);
        }
        else
        {
            Debug.Log("没有出现交叉依赖");
        }
    }
Exemple #2
0
        private string[] GetDependencies(string assetBundleName, bool isScene = false)
        {
            string[] dependencies = new string[0];
            if (DependenciesCache.TryGetValue(assetBundleName, out dependencies))
            {
                return(dependencies);
            }

            if (!Define.IsAsync)
            {
#if UNITY_EDITOR
                if (isScene == false)
                {
                    dependencies = AssetDatabase.GetAssetBundleDependencies(assetBundleName, true);
                }
#endif
            }
            else
            {
                dependencies = this.AssetBundleManifestObject.GetAllDependencies(assetBundleName);
            }

            DependenciesCache.Add(assetBundleName, dependencies);
            return(dependencies);
        }
Exemple #3
0
        private static void ProcessAssetBundleRes(AssetDataTable table)
        {
            AssetDataGroup group = null;

            AssetDatabase.RemoveUnusedAssetBundleNames();

            string[] abNames = AssetDatabase.GetAllAssetBundleNames();
            if (abNames != null && abNames.Length > 0)
            {
                for (int i = 0; i < abNames.Length; ++i)
                {
                    string[] depends = AssetDatabase.GetAssetBundleDependencies(abNames[i], false);
                    var      abIndex = table.AddAssetBundleName(abNames[i], depends, out group);
                    if (abIndex < 0)
                    {
                        continue;
                    }

                    string[] assets = AssetDatabase.GetAssetPathsFromAssetBundle(abNames[i]);
                    foreach (var cell in assets)
                    {
                        if (cell.EndsWith(".unity"))
                        {
                            group.AddAssetData(new AssetData(AssetPath2Name(cell), ResType.ABScene, abIndex, abNames[i]));
                        }
                        else
                        {
                            group.AddAssetData(new AssetData(AssetPath2Name(cell), ResType.ABAsset, abIndex, abNames[i]));
                        }
                    }
                }
            }

            table.Dump();
        }
Exemple #4
0
    public void LoadAssetBoundles()
    {
        UnloadAssetBoundles();

        enties = new List <Entiy>();
        foreach (Object target in Selection.objects)
        {
            if (target is DefaultAsset)
            {
                string      path = AssetDatabase.GetAssetPath(target);
                AssetBundle ab   = AssetBundle.LoadFromFile(path);
                if (ab == null)
                {
                    break;
                }

                Object[] assets  = ab.LoadAllAssets().OrderBy(x => x.GetType().Name).ThenBy(x => x.name).ToArray();
                Object[] depends = EditorUtility.CollectDependencies(assets).Except(assets).OrderBy(x => x.GetType().Name).ThenBy(x => x.name).ToArray();
                enties.Add(new Entiy()
                {
                    ab        = ab,
                    abDepends = AssetDatabase.GetAssetBundleDependencies(ab.name, false),
                    assets    = assets,
                    depends   = depends
                });
            }
        }

        this.Repaint();
    }
Exemple #5
0
        public static void PrepareBundleAssetsMap()
        {
            BundleManifest manifest = AssetDatabase.LoadAssetAtPath <BundleManifest>(manifestAssetPath);

            if (manifest == null)
            {
                manifest = ScriptableObject.CreateInstance <BundleManifest>();
                AssetDatabase.CreateAsset(manifest, manifestAssetPath);
            }
            else
            {
                manifest.ClearBundleData();
            }
            string[] bundleNames = AssetDatabase.GetAllAssetBundleNames();
            foreach (string bundleName in bundleNames)
            {
                foreach (string assetName in AssetDatabase.GetAssetPathsFromAssetBundle(bundleName))
                {
                    manifest.AddBundleAssetPath(assetName, bundleName);
                }

                manifest.AddBundleData(bundleName, AssetDatabase.GetAssetBundleDependencies(bundleName, true));
            }
            EditorUtility.SetDirty(manifest);

            AssetDatabase.LoadAssetAtPath <BundleManifest>(manifestAssetPath);
            AssetImporter importer = AssetImporter.GetAtPath(manifestAssetPath);

            importer.assetBundleName = manifestName;
        }
        private static void ProcessAssetBundleRes(ResDatas table)
        {
            AssetDatabase.RemoveUnusedAssetBundleNames();

            var abNames = AssetDatabase.GetAllAssetBundleNames();

            if (abNames != null && abNames.Length > 0)
            {
                foreach (var abName in abNames)
                {
                    var            depends = AssetDatabase.GetAssetBundleDependencies(abName, false);
                    AssetDataGroup group;
                    var            abIndex = table.AddAssetBundleName(abName, depends, out @group);
                    if (abIndex < 0)
                    {
                        continue;
                    }

                    var assets = AssetDatabase.GetAssetPathsFromAssetBundle(abName);
                    foreach (var cell in assets)
                    {
                        @group.AddAssetData(cell.EndsWith(".unity")
                            ? new AssetData(AssetPath2Name(cell), ResType.ABScene, abIndex, abName)
                            : new AssetData(AssetPath2Name(cell), ResType.ABAsset, abIndex, abName));
                    }
                }
            }
        }
Exemple #7
0
        public static AssetCatalog CreateEditorAssetCatalog()
        {
            Dictionary <string, AssetInfo>       assets       = new Dictionary <string, AssetInfo>();
            Dictionary <string, AssetBundleInfo> assetBundles = new Dictionary <string, AssetBundleInfo>();

            foreach (string assetBundleName in AssetDatabase.GetAllAssetBundleNames())
            {
                string[] assetsInAssetBundle = AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName);

                foreach (string asset in assetsInAssetBundle)
                {
                    AssetInfo assetInfo = new AssetInfo
                    {
                        AssetName       = asset,
                        AssetBundleName = assetBundleName
                    };
                    assets.Add(asset, assetInfo);
                    assets.Add(AssetDatabase.AssetPathToGUID(asset), assetInfo);
                }

                assetBundles.Add(assetBundleName, new AssetBundleInfo
                {
                    FileName     = assetBundleName,
                    Assets       = assetsInAssetBundle,
                    Dependencies = AssetDatabase.GetAssetBundleDependencies(assetBundleName, false)
                });
            }

            return(new AssetCatalog
            {
                Assets = assets,
                AssetBundles = assetBundles
            });
        }
Exemple #8
0
        /** 生成依赖 */
        private void createDepends()
        {
            EditorUtility.DisplayProgressBar("请耐心等待", "正在检测bundle依赖...", 0.0f);

            int progressNum = _bundleInfoExDataList.length();
            int curNum      = 0;

            foreach (BundleInfoExData bundleInfoExData in _bundleInfoExDataList)
            {
                string[] dependencies = AssetDatabase.GetAssetBundleDependencies(bundleInfoExData.name, true);
                string[] depends      = new string[dependencies.Length];

                for (int i = 0; i < dependencies.Length; i++)
                {
                    string name = dependencies[i];
                    bundleInfoExData.depends.add(_resourceInfoExDataCache[name].id);
                }

                EditorUtility.DisplayProgressBar("请耐心等待", "正在检测bundle依赖...", (float)++curNum / progressNum);

                _bundleInfoDataList[bundleInfoExData.name].depends = bundleInfoExData.depends.toArray();
            }

            EditorUtility.ClearProgressBar();

            EditorUtility.DisplayProgressBar("请耐心等待", "正在检测bundle循环依赖...", 0.0f);

            chechResourceLoopDepend();
        }
Exemple #9
0
        private void doChechResourceLoopDepend(string path, string bundleName)
        {
            if (!ShineSetting.openBundleCheckLoop)
            {
                return;
            }

            string[] dependencies = AssetDatabase.GetAssetBundleDependencies(bundleName, true);

            for (int i = 0; i < dependencies.Length; i++)
            {
                string localName = dependencies[i];

                if (path.IndexOf(localName) != -1)
                {
                    path += "-->" + localName;
                    //检测到循环
                    Ctrl.errorLog("检测到循环依赖", path);
                    return;
                }

                path += "-->" + localName;

                doChechResourceLoopDepend(path, localName);
            }
        }
Exemple #10
0
        public void AddABInfo2ResDatas(IResDatas assetBundleConfigFile)
        {
#if UNITY_EDITOR
            AssetDatabase.RemoveUnusedAssetBundleNames();

            var abNames = AssetDatabase.GetAllAssetBundleNames();
            if (abNames != null && abNames.Length > 0)
            {
                foreach (var abName in abNames)
                {
                    var            depends = AssetDatabase.GetAssetBundleDependencies(abName, false);
                    AssetDataGroup group;
                    var            abIndex = assetBundleConfigFile.AddAssetBundleName(abName, depends, out @group);
                    if (abIndex < 0)
                    {
                        continue;
                    }

                    var assets = AssetDatabase.GetAssetPathsFromAssetBundle(abName);
                    foreach (var cell in assets)
                    {
                        var type = AssetDatabase.GetMainAssetTypeAtPath(cell);

                        var code = type.ToCode();

                        @group.AddAssetData(cell.EndsWith(".unity")
                            ? new AssetData(AssetPath2Name(cell), ResLoadType.ABScene, abIndex, abName, code)
                            : new AssetData(AssetPath2Name(cell), ResLoadType.ABAsset, abIndex, abName, code));
                    }
                }
            }
#endif
        }
Exemple #11
0
        public static void ProcessAssetBundleRes(AssetDataTable table)
        {
            var abNameArr = AssetDatabase.GetAllAssetBundleNames();

            if (abNameArr != null && abNameArr.Length > 0)
            {
                foreach (var abName in abNameArr)
                {
                    var dependArr = AssetDatabase.GetAssetBundleDependencies(abName, false);
                    AssetDataPackage group;
                    var abIndex = table.AddAssetBundleMsg(abName, dependArr, out group);
                    if (abIndex < 0)
                    {
                        continue;
                    }
                    var assets = AssetDatabase.GetAssetPathsFromAssetBundle(abName);
                    foreach (var cell in assets)
                    {
                        //var type = AssetDatabase.GetMainAssetTypeAtPath(cell);
                        //var code = type.ToCode();

                        group.AddAssetData(cell.EndsWith(".unity")
                            ? new AssetData(AssetPath2Name(cell), ResLoadType.ABScene, abIndex, abName)
                            : new AssetData(AssetPath2Name(cell), ResLoadType.ABAsset, abIndex, abName));
                    }
                }
            }
        }
        /// <summary>
        /// 创建模块的依赖关系文件
        /// </summary>
        /// <param name="_path"></param>
        /// <param name="_moduleName"></param>
        /// <param name="_assetBundleExtension"></param>
        public static void CreateModuleManifest(string _path, string _moduleName, string _assetBundleExtension)
        {
            string manifestContent = "";

            List <string> bundleNameOfModule = GetAssetBundleNamesByModule(_moduleName);

            foreach (var v in bundleNameOfModule)
            {
                string[] refs = AssetDatabase.GetAssetBundleDependencies(v, true);

                if (refs.Length == 0)
                {
                    continue;
                }

                manifestContent += string.Format("{0}:{1}\r\n", GetFileName(v), StrArrayToString(refs));
            }

            string fileDir = GetDiskPath(_path + "/manifest.txt");

            File.WriteAllText(fileDir, manifestContent);
            AssetDatabase.Refresh();
            AssetImporter setting = AssetImporter.GetAtPath(_path + "/manifest.txt");

            setting.SetAssetBundleNameAndVariant(_moduleName, _assetBundleExtension);
            AssetDatabase.Refresh();
        }
Exemple #13
0
        public static string[] GetAssetBundleDependencies(string assetBundleName, bool recursive)
        {
#if UNITY_EDITOR
            return(AssetDatabase.GetAssetBundleDependencies(assetBundleName, recursive));
#else
            return(null);
#endif
        }
Exemple #14
0
    private void CollectRepeatAssets()
    {
        abAssetDict = new Dictionary <string, HashSet <Object> >();

        //获得ab依赖的所有资源
        string[] abNames = AssetDatabase.GetAllAssetBundleNames();
        foreach (string abName in abNames)
        {
            string[]      assetPaths = AssetDatabase.GetAssetPathsFromAssetBundle(abName);
            List <Object> objects    = new List <Object>();
            foreach (string assetPath in assetPaths)
            {
                objects.AddRange(AssetDatabase.LoadAllAssetsAtPath(assetPath));
            }
            HashSet <Object> abAssets = new HashSet <Object>(EditorUtility.CollectDependencies(objects.ToArray()));
            abAssetDict.Add(abName, abAssets);
        }
        //移除ab间依赖
        foreach (var pair in abAssetDict)
        {
            string[] dependAbs = AssetDatabase.GetAssetBundleDependencies(pair.Key, true);
            foreach (string depend in dependAbs)
            {
                foreach (Object obj in abAssetDict[depend])
                {
                    pair.Value.Remove(obj);
                }
            }
        }
        //统计
        repeatCount = new Dictionary <Object, List <RepeatData> >();
        foreach (var pair in abAssetDict)
        {
            foreach (Object obj in pair.Value)
            {
                if (obj is MonoScript)
                {
                    continue;
                }

                RepeatData repeatData = new RepeatData();
                repeatData.abName = pair.Key;
                if (!repeatCount.ContainsKey(obj))
                {
                    repeatCount.Add(obj, new List <RepeatData>()
                    {
                        repeatData
                    });
                }
                else
                {
                    repeatCount[obj].Add(repeatData);
                }
            }
        }
    }
Exemple #15
0
        public static string[] GetDependencies(string assetBundleName)
        {
            string[] dependencies = new string[0];
#if UNITY_EDITOR
            dependencies = AssetDatabase.GetAssetBundleDependencies(assetBundleName, true);
#elif UNITY_STANDALONE
            dependencies = ResourcesComponent.assetBundleManifestObject.GetAllDependencies(assetBundleName);
#endif
            return(dependencies);
        }
 /// <summary>
 /// 添加依赖
 /// </summary>
 /// <param name="dependences">依赖</param>
 /// <param name="ai">资源导入</param>
 public static void AddDependences(Dictionary <string, AssetBundleInfo> dependences, AssetImporter ai)
 {
     if (!dependences.ContainsKey(ai.assetBundleName))
     {
         string          assetBundleName = ai.assetBundleName + "." + ai.assetBundleVariant;
         AssetBundleInfo info            = new AssetBundleInfo(assetBundleName, AssetDatabase.GetAssetBundleDependencies(assetBundleName, false));
         dependences.Add(ai.assetBundleName, info);
         CheckDependences(assetBundleName, assetBundleName, string.Empty, new List <string>());
     }
 }
Exemple #17
0
 public static void Refresh()
 {
     bundleList.Clear();
     foreach (string bundleName in AssetDatabase.GetAllAssetBundleNames())
     {
         BundleInfo bundleInfo = new BundleInfo(bundleName, AssetDatabase.GetAssetPathsFromAssetBundle(bundleName),
                                                AssetDatabase.GetAssetBundleDependencies(bundleName, false),
                                                AssetDatabase.GetAssetBundleDependencies(bundleName, true));
         bundleList.Add(bundleInfo);
     }
 }
        private static void ProcessAssetBundleRes(AssetDataTable table, string[] abNames)
        {
            AssetDataPackage group = null;

            int abIndex = -1;

            AssetDatabase.RemoveUnusedAssetBundleNames();

            if (abNames == null)
            {
                abNames = AssetDatabase.GetAllAssetBundleNames();
            }

            if (abNames != null && abNames.Length > 0)
            {
                for (int i = 0; i < abNames.Length; ++i)
                {
                    string abPath = Application.dataPath + "/" + ProjectPathConfig.exportRootFolder + abNames[i];

                    string[] depends = AssetDatabase.GetAssetBundleDependencies(abNames[i], false);

                    FileInfo info = new FileInfo(abPath);
                    if (!info.Exists)
                    {
                        continue;
                    }
                    string md5       = GetMD5HashFromFile(abPath);
                    long   buildTime = DateTime.Now.Ticks; //info.LastWriteTime.Ticks;

                    abIndex = table.AddAssetBundleName(abNames[i], depends, md5, (int)info.Length, buildTime, out group);
                    if (abIndex < 0)
                    {
                        continue;
                    }
                    //Log.i("MD5:" + GetMD5HashFromFile(abPath));

                    string[] assets = AssetDatabase.GetAssetPathsFromAssetBundle(abNames[i]);
                    foreach (var cell in assets)
                    {
                        if (cell.EndsWith(".unity"))
                        {
                            group.AddAssetData(new AssetData(AssetPath2Name(cell), eResType.kABScene, abIndex));
                        }
                        else
                        {
                            group.AddAssetData(new AssetData(AssetPath2Name(cell), eResType.kABAsset, abIndex));
                        }
                    }
                }
            }

            table.Dump();
        }
Exemple #19
0
 /// <summary>
 ///     <para> 收集ab的依赖关系 </para>
 /// </summary>
 static void CollectAssetBundleDependencies()
 {
     foreach (var assetBundleData in s_AssetBundleDatas)
     {
         string[] depends = AssetDatabase.GetAssetBundleDependencies(assetBundleData.Key, false);
         foreach (string depend in depends)
         {
             AssetBundleData data = s_AssetBundleDatas[depend];
             assetBundleData.Value.childs.Add(data.name);
             data.parents.Add(assetBundleData.Value.name);
         }
     }
 }
Exemple #20
0
        public AssetBundleInfoWithDepends(string name)
        {
            this.assetBundleName = name;

            string[] depends = AssetDatabase.GetAssetBundleDependencies(this.assetBundleName, true);
            if (depends == null)
            {
                return;
            }
            foreach (var depend in depends)
            {
                AddList(depend, ref this.dependsAssetBundleList);
            }
        }
Exemple #21
0
        protected override void ContextClickedItem(int id)
        {
            // todo 右键菜单添加展开选择的多个父节点的功能
            var viewItem = FindItem(id, rootItem);
            var menu     = new GenericMenu();

            if (viewItem.depth == 1)
            {
                menu.AddItem(new GUIContent("Ping"),
                             false,
                             () => (viewItem as BundleAssetTreeViewItem).Ping());
            }

            // todo 删除时需要提醒当前bundle是否被AssetBundleReference或者AssetReference引用
            menu.AddItem(new GUIContent("Delete"), false, () =>
            {
                IList <int> selection = GetSelection();
                IOrderedEnumerable <TreeViewItem> rows = FindRows(selection).OrderByDescending(x => x.id);
                foreach (var item in rows.Where(x => x.depth == 0).Cast <BundleTreeViewItem>())
                {
                    item.Delete();
                }

                foreach (var item in rows.Where(x => x.depth == 1).Cast <BundleAssetTreeViewItem>())
                {
                    item.Delete();
                }

                Reload();
            });

            if (viewItem.depth == 0)
            {
                menu.AddItem(new GUIContent("Select Dependencies"), false, () =>
                {
                    int selectId     = GetSelection().First();
                    var item         = FindItem(selectId, rootItem);
                    var dependencies = AssetDatabase.GetAssetBundleDependencies(item.displayName, true)
                                       .Select(x => _abName2ViewItemId[x])
                                       .ToList();
                    if (dependencies.Count == 0)
                    {
                        return;
                    }
                    SetSelection(dependencies);
                });
            }
            menu.ShowAsContext();
        }
Exemple #22
0
        public static string[] GetDependencies(string assetBundleName)
        {
            string[] dependencies = new string[0];
            if (!Define.IsAsync)
            {
#if UNITY_EDITOR
                dependencies = AssetDatabase.GetAssetBundleDependencies(assetBundleName, true);
#endif
            }
            else
            {
                dependencies = ResourcesComponent.AssetBundleManifestObject.GetAllDependencies(assetBundleName);
            }
            return(dependencies);
        }
Exemple #23
0
        public static string[] GetDependencies(string assetBundleName)
        {
            string[] dependencies = new string[0];
            if (DependenciesCache.TryGetValue(assetBundleName, out dependencies))
            {
                return(dependencies);
            }
            //if (!Define.IsAsync)
#if UNITY_EDITOR
            dependencies = AssetDatabase.GetAssetBundleDependencies(assetBundleName, true);
#else
            dependencies = ResourcesManager.AssetBundleManifestObject.GetAllDependencies(assetBundleName);
#endif

            return(dependencies);
        }
    // 收集ab的依赖关系
    static void CollectAssetBundleDependencies()
    {
        var iter = m_datas.GetEnumerator();

        while (iter.MoveNext())
        {
            AssetBundleData current = iter.Current.Value;
            string[]        depends = AssetDatabase.GetAssetBundleDependencies(iter.Current.Key, false);
            foreach (string depend in depends)
            {
                AssetBundleData data = m_datas[depend];
                current.childs.Add(data.name);
                data.parents.Add(current.name);
            }
        }
    }
        private static void ProcessAssetBundleRes(AssetDataTable table, string[] abNames)
        {
            AssetDataPackage package = null;

            //int abIndex = -1;
            AssetDatabase.RemoveUnusedAssetBundleNames();
            if (abNames == null)
            {
                abNames = AssetDatabase.GetAllAssetBundleNames();
            }

            if (abNames != null && abNames.Length > 0)
            {
                for (int i = 0; i < abNames.Length; ++i)
                {
                    //输出路径
                    string abPath = Path.Combine(FilePath.streamingAssetsPath4AB, abNames[i]);

                    string[] depends = AssetDatabase.GetAssetBundleDependencies(abNames[i], false);
                    FileInfo info    = new FileInfo(abPath);
                    if (!info.Exists)
                    {
                        continue;
                    }
                    string md5        = GetMD5HashFromFile(abPath);
                    long   buildTime  = System.DateTime.Now.Ticks;
                    bool   successAdd = table.AddAssetBundle(abNames[i], depends, md5, (int)info.Length, buildTime, out package);
                    if (!successAdd)
                    {
                        continue;
                    }

                    string[] assets = AssetDatabase.GetAssetPathsFromAssetBundle(abNames[i]);
                    foreach (var cell in assets)
                    {
                        // if (cell.EndsWith(".unity"))
                        // {
                        //     package.AddAssetData(new AssetData(AssetPath2Name(cell), eResType.kABScene));//, -1));
                        // }
                        // else
                        {
                            package.AddAssetData(new AssetData(PathHelper.Path2Name(cell), eResType.kABAsset));//, -1));
                        }
                    }
                }
            }
        }
Exemple #26
0
        static void CheckAssetBundleCrossReference()
        {
            List <string> abList = new List <string>(AssetDatabase.GetAllAssetBundleNames());
            Dictionary <string, string[]> depDict = new Dictionary <string, string[]>();

            for (int i = 0; i < abList.Count; i++)
            {
                var ab   = abList[i];
                var deps = AssetDatabase.GetAssetBundleDependencies(ab, false);
                if (deps != null && deps.Length > 0)
                {
                    depDict[ab] = deps;
                }
                else
                {
                    abList.RemoveAt(i);
                    --i;
                }
            }

            for (int i = 0; i < abList.Count; i++)
            {
                var ab = abList[i];

                string[] deps = null;
                if (depDict.TryGetValue(ab, out deps))
                {
                    foreach (var dep in deps)
                    {
                        string[] depdeps = null;
                        if (depDict.TryGetValue(dep, out depdeps))
                        {
                            foreach (var depdep in depdeps)
                            {
                                if (depdep == ab)
                                {
                                    Debug.Log("cross reference: " + ab + " <-> " + dep);
                                }
                            }
                        }
                    }
                    depDict.Remove(ab);
                }
            }

            Debug.Log("Check AssetBundle Cross reference done");
        }
Exemple #27
0
    private void ShowAssets(string abName)
    {
        HashSet <Object> abValues = abAssetDict[abName];

        EditorGUI.indentLevel++;
        foreach (var asset in abValues)
        {
            ShowAsset(asset);
        }
        string[] dependAbs = AssetDatabase.GetAssetBundleDependencies(abName, false);
        foreach (string depend in dependAbs)
        {
            EditorGUILayout.LabelField(depend);
            ShowAssets(depend);
        }
        EditorGUI.indentLevel--;
    }
Exemple #28
0
    public void LoadAssetBoundles()
    {
        UnloadAssetBoundles();
        openedAsset = new HashSet <Object>();

        enties = new List <ABEntiy>();
        foreach (Object target in Selection.objects)
        {
            if (target is DefaultAsset)
            {
                string      path = AssetDatabase.GetAssetPath(target);
                AssetBundle ab   = null;
                try{
                    ab = AssetBundle.LoadFromFile(path);
                }catch {
                }
                if (ab == null)
                {
                    return;
                }
                Object[]     assets      = ab.LoadAllAssets().Where(x => !(x is MonoScript) && x != null).OrderBy(x => x.GetType().Name).ThenBy(x => x.name).ToArray();
                int          count       = assets.Length;
                AssetEntiy[] assetEntiys = new AssetEntiy[count];
                for (int i = 0; i < count; i++)
                {
                    Object asset = assets[i];
                    assetEntiys[i] = new AssetEntiy()
                    {
                        asset = asset, depends = EditorUtility.CollectDependencies(new Object[] { asset }).Where(x => !(x is MonoScript) && x != null).Except(new Object[] { asset }).OrderBy(x => x.GetType().Name).ThenBy(x => x.name).ToArray()
                    };
                }

                enties.Add(new ABEntiy()
                {
                    ab        = ab,
                    abDepends = AssetDatabase.GetAssetBundleDependencies(ab.name, false),
                    assets    = assetEntiys,
                    depends   = assetEntiys.SelectMany(x => x.depends).Distinct().OrderBy(x => x.GetType().Name).ThenBy(x => x.name).ToArray()
                });
            }
        }

        this.Repaint();
    }
Exemple #29
0
        private static void BuildAssetBundlesXMLManifest(string rootPath)
        {
            ABManifest manifest = new ABManifest();

            foreach (var abName in AssetDatabase.GetAllAssetBundleNames())
            {
                ABItem aBItem = new ABItem();
                aBItem.name = abName;
                string abFile = Path.Combine(rootPath, abName);
                aBItem.fileSizeInBytes = new FileInfo(abFile).Length;
                aBItem.md5             = FileUtils.GetMD5HashFromFile(abFile);
                aBItem.dependencies    = AssetDatabase.GetAssetBundleDependencies(abName, false);
                manifest.abItems.Add(aBItem);
            }
            string manifestXmlFile = Path.Combine(rootPath, ABManifest.FileName);

            manifest.Serialize(manifestXmlFile);
            ShowABManifest(manifestXmlFile);
        }
Exemple #30
0
        public static void CreateDepFile(string[] assetBundles)
        {
            List <List <string> > resultMap = new List <List <string> >();
            int length = assetBundles.Length;

            for (int i = 0; i < length; i++)
            {
                List <string> result = new List <string>();
                string[]      deps   = AssetDatabase.GetAssetBundleDependencies(assetBundles[i], true);
                result.Add(assetBundles[i]);
                result.Add(deps.Length.ToString());
                for (int k = 0; k < deps.Length; k++)
                {
                    result.Add(deps[k]);
                }
                resultMap.Add(result);
            }
            CreateConfig(resultMap, AssetBundleConst.DepConfigName);
        }