GetAll() public static method

public static GetAll ( ) : List
return List
Exemplo n.º 1
0
        public override void Export()
        {
            try
            {
                base.Export();

                //Build Export Tree
                var all = AssetBundleUtils.GetAll();
                List <List <AssetTarget> > tree = new List <List <AssetTarget> >();
                foreach (AssetTarget target in all)
                {
                    target.AnalyzeIfDepTreeChanged();
                    BuildExportTree(target, tree, 0);
                }

                //Export
                this.Export(tree, 0);
                this.SaveDepAll(all);
                this.RemoveUnused(all);
                AssetDatabase.Refresh();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
Exemplo n.º 2
0
        public void ExportImp()
        {
            AssetBundleManager.Log("building... cur Time " + Time.realtimeSinceStartup);

            List <AssetBundleBuild> list = new List <AssetBundleBuild>();
            //标记所有 asset bundle name
            var all      = AssetBundleUtils.GetAll();
            var abAssets = new Dictionary <string, HashSet <AssetTarget> >();

            for (int i = 0; i < all.Count; i++)
            {
                AssetTarget target = all[i];
                if (target.needSelfExport)
                {
                    if (!abAssets.ContainsKey(target.abFileName))
                    {
                        abAssets.Add(target.abFileName, new HashSet <AssetTarget>());
                    }
                    abAssets[target.abFileName].Add(target);
                    AssetBundleBuild build = new AssetBundleBuild();
                    build.assetBundleName = target.abFileName;
                    build.assetNames      = new string[] { target.assetPath };
                    list.Add(build);
                }
            }

            AssetBundleManager.Log("building... cur Time " + Time.realtimeSinceStartup);
            //开始打包
            BuildAssetBundleOptions buildOptions = BuildAssetBundleOptions.DeterministicAssetBundle |
                                                   BuildAssetBundleOptions.ChunkBasedCompression |
                                                   BuildAssetBundleOptions.DisableWriteTypeTree;

            BuildPipeline.BuildAssetBundles(pathResolver.BundleSavePath, list.ToArray(), buildOptions,
                                            EditorUserBuildSettings.activeBuildTarget);
            AssetBundleManager.Log("building... cur Time " + Time.realtimeSinceStartup);
            AssetBundle         ab       = AssetBundle.LoadFromFile(pathResolver.BundleSavePath + "/AssetBundles");
            AssetBundleManifest manifest = ab.LoadAsset("AssetBundleManifest") as AssetBundleManifest;

            //hash
            for (int i = 0; i < all.Count; i++)
            {
                AssetTarget target = all[i];
                if (target.needSelfExport)
                {
                    Hash128 hash = manifest.GetAssetBundleHash(target.abFileName);
                    target.bundleCrc = hash.ToString();
                }
            }
            this.SaveDepAll(all, manifest, abAssets);
            this.RemoveUnused(all, manifest);
            ab.Unload(true);
            AssetBundleManager.Log("building... cur Time " + Time.realtimeSinceStartup);
            AssetDatabase.RemoveUnusedAssetBundleNames();
            AssetDatabase.Refresh();
            AssetBundleManager.Log("building... cur Time " + Time.realtimeSinceStartup);
        }
        public override void Export()
        {
            base.Export();

            List <AssetBundleBuild> list = new List <AssetBundleBuild>();
            //标记所有 asset bundle name
            var all = AssetBundleUtils.GetAll();

            for (int i = 0; i < all.Count; i++)
            {
                AssetTarget target = all[i];
                if (target.needSelfExport)
                {
                    AssetBundleBuild build = new AssetBundleBuild();
                    build.assetBundleName = target.bundleName;
                    build.assetNames      = new string[] { target.assetPath };
                    list.Add(build);
                }
            }
            ///加入图集
            for (int index = 1; index <= 1; index++)
            {
                Debug.Log(index);
                string           assetResPath = "Assets/Textures/Common" + index;
                AssetBundleBuild rABB         = new AssetBundleBuild();
                rABB.assetBundleName    = "common" + index;
                rABB.assetBundleVariant = "ab";
                rABB.assetNames         = new string[] { assetResPath };
                list.Add(rABB);
            }
            //开始打包
            BuildPipeline.BuildAssetBundles(pathResolver.BundleSavePath, list.ToArray(), BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
#if UNITY_5_1 || UNITY_5_2
            AssetBundle ab = AssetBundle.CreateFromFile(pathResolver.BundleSavePath + "/AssetBundles");
#else
            AssetBundle ab = AssetBundle.LoadFromFile(pathResolver.BundleSavePath + "/AssetBundles");
#endif
            AssetBundleManifest manifest = ab.LoadAsset("AssetBundleManifest") as AssetBundleManifest;
            //hash
            for (int i = 0; i < all.Count; i++)
            {
                AssetTarget target = all[i];
                if (target.needSelfExport)
                {
                    Hash128 hash = manifest.GetAssetBundleHash(target.bundleName);
                    target.bundleCrc = hash.ToString();
                }
            }
            this.SaveDepAll(all);
            ab.Unload(true);
            this.RemoveUnused(all);
            AssetDatabase.RemoveUnusedAssetBundleNames();
            AssetDatabase.Refresh();
        }
Exemplo n.º 4
0
        public override void Export()
        {
            base.Export();

            //标记所有 asset bundle name
            var all = AssetBundleUtils.GetAll();

            for (int i = 0; i < all.Count; i++)
            {
                AssetTarget   target   = all[i];
                AssetImporter importer = AssetImporter.GetAtPath(target.assetPath);
                if (importer)
                {
                    if (target.needSelfExport)
                    {
                        importer.assetBundleName = target.bundleName;
                    }
                    else
                    {
                        importer.assetBundleName = null;
                    }
                }
            }

            //开始打包
            BuildPipeline.BuildAssetBundles(this.pathResolver.BundleSavePath, BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);

#if UNITY_5_1 || UNITY_5_2
            AssetBundle ab = AssetBundle.CreateFromFile(pathResolver.BundleSavePath + "/AssetBundles");
#else
            AssetBundle ab = AssetBundle.LoadFromFile(pathResolver.BundleSavePath + "/AssetBundles");
#endif
            AssetBundleManifest manifest = ab.LoadAsset("AssetBundleManifest") as AssetBundleManifest;
            //清除所有 asset bundle name
            for (int i = 0; i < all.Count; i++)
            {
                AssetTarget target = all[i];
                Hash128     hash   = manifest.GetAssetBundleHash(target.bundleName);
                target.bundleCrc = hash.ToString();

                AssetImporter importer = AssetImporter.GetAtPath(target.assetPath);
                if (importer)
                {
                    importer.assetBundleName = null;
                }
            }
            this.SaveDepAll(all);
            ab.Unload(true);
            this.RemoveUnused(all);

            AssetDatabase.RemoveUnusedAssetBundleNames();
            AssetDatabase.Refresh();
        }
        public override void Export()
        {
            base.Export();

            List <AssetBundleBuild> list = new List <AssetBundleBuild>();
            //标记所有 asset bundle name
            var all = AssetBundleUtils.GetAll();

            for (int i = 0; i < all.Count; i++)
            {
                AssetTarget target = all[i];
                if (target.needSelfExport)
                {
                    AssetBundleBuild build = new AssetBundleBuild();
                    build.assetBundleName = target.bundleName;
                    build.assetNames      = new string[] { target.assetPath };
                    list.Add(build);
                }
            }
            //这是自动根据依赖关系分析出来的bundle划分
            //接下来我们可以再自定义一部分assetbundleBuild 自定义一部分bundle  可以假设一群asset其实就是一个assetTarget来去参与分析依赖关系


            //开始打包
            BuildPipeline.BuildAssetBundles(pathResolver.BundleSavePath, list.ToArray(), BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);

#if UNITY_5_1 || UNITY_5_2
            AssetBundle ab = AssetBundle.CreateFromFile(pathResolver.BundleSavePath + "/AssetBundles");
#else
            AssetBundle ab = AssetBundle.LoadFromFile(pathResolver.BundleSavePath + "/AssetBundles");
#endif
            AssetBundleManifest manifest = ab.LoadAsset("AssetBundleManifest") as AssetBundleManifest;
            //hash
            for (int i = 0; i < all.Count; i++)
            {
                AssetTarget target = all[i];
                if (target.needSelfExport)
                {
                    Hash128 hash = manifest.GetAssetBundleHash(target.bundleName);
                    target.bundleCrc = hash.ToString();
                }
            }
            this.SaveDepAll(all);
            ab.Unload(true);
            this.RemoveUnused(all);

            AssetDatabase.RemoveUnusedAssetBundleNames();
            AssetDatabase.Refresh();
        }
Exemplo n.º 6
0
        public override void Export()
        {
#if USE_SPRITEATLAS
            SpriteAtlasUtility.PackAllAtlases(EditorUserBuildSettings.activeBuildTarget, false);
#endif
            base.Export(); //分析依赖关系
            var all = AssetBundleUtils.GetAll();
            try
            {
                SetSpriteAtlasInBuild(all, false);
                ExportImp();
            }
            finally
            {
                SetSpriteAtlasInBuild(all, true);
            }
        }
Exemplo n.º 7
0
        public virtual void Analyze()
        {
            var all = AssetBundleUtils.GetAll();

            foreach (AssetTarget target in all)
            {
                target.Analyze();
            }
            all = AssetBundleUtils.GetAll();
            foreach (AssetTarget target in all)
            {
                target.Merge();
            }
            all = AssetBundleUtils.GetAll();
            foreach (AssetTarget target in all)
            {
                target.BeforeExport();
            }
        }
Exemplo n.º 8
0
        public virtual void Analyze()
        {
            var all = AssetBundleUtils.GetAll();

            //主要是把所有用到的asset集合起来,分析依赖关系,构建依赖树
            foreach (AssetTarget target in all)
            {
                target.Analyze();
            }
            all = AssetBundleUtils.GetAll();
            //感觉前两步仅仅是为了获取GetDirectDependencies,
            foreach (AssetTarget target in all)
            {
                target.Merge();
            }
            all = AssetBundleUtils.GetAll();
            //以root为启动,标记stanalone,再在root和standalone基础上 循环标记一批standalone asset
            foreach (AssetTarget target in all)
            {
                target.BeforeExport();
            }
        }