Esempio n. 1
0
        protected virtual void BuildAssetBundles()
        {
            var buildInfo = new AssetBundleBuildInfo();

            buildInfo.OutputPath            = m_outputPath;
            buildInfo.Target                = m_buildTarget;
            buildInfo.CleanFolders          = m_clearFolders;
            buildInfo.CopyToStreamingAssets = m_copyToStreamingAssets;
            buildInfo.BuildOptions          = m_buildAssetBundleOptions;

            AssetBundleBuilder.Build(buildInfo);
        }
Esempio n. 2
0
        public static void Build(AssetBundleBuildInfo buildInfo)
        {
            AssetBundleNameBuilder.Build();

            AssetDatabase.Refresh();
            AssetDatabase.RemoveUnusedAssetBundleNames();

            if (buildInfo.CleanFolders)
            {
                if (Directory.Exists(buildInfo.OutputPath))
                {
                    Directory.Delete(buildInfo.OutputPath, true);
                }
            }

            if (!Directory.Exists(buildInfo.OutputPath))
            {
                Directory.CreateDirectory(buildInfo.OutputPath);
            }

            if (buildInfo.SpecificAssetBundles == null || buildInfo.SpecificAssetBundles.Length == 0)
            {
                BuildPipeline.BuildAssetBundles(buildInfo.OutputPath, buildInfo.BuildOptions, buildInfo.Target);
            }
            else
            {
                BuildPipeline.BuildAssetBundles(buildInfo.OutputPath, buildInfo.SpecificAssetBundles, buildInfo.BuildOptions, buildInfo.Target);
            }

            AssetBundleCatalogBuilder.Build(buildInfo.OutputPath);

            if (buildInfo.CopyToStreamingAssets)
            {
                var streamingAssetsPath = Path.Combine(STREAMING_ASSETS_FOLDER_PATH, AssetBundleDef.ASSET_BUNDLE_OUTPUT_FOLDER);
                streamingAssetsPath = Path.Combine(streamingAssetsPath, AssetBundleDef.GetPlatformName());

                if (Directory.Exists(streamingAssetsPath))
                {
                    Directory.Delete(streamingAssetsPath, true);
                }

                DirectoryCopy(buildInfo.OutputPath, streamingAssetsPath);
            }

            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);

            TEDDebug.Log("Build AssetBundles successfully.");
        }