Пример #1
0
        /// <summary>
        /// 根据项目中的配置进行AB打包
        /// </summary>
        /// <param name="assetBundleManifest"></param>
        /// <param name="setting"><see cref="PackBundleSetting"/></param>
        /// <returns></returns>
        public static bool PackBundle(out AssetBundleManifest assetBundleManifest, PackBundleSetting setting)
        {
            assetBundleManifest = null;

            if (setting.UpdateConfigs)
            {
                if (!GenerateConfigs())
                {
                    return(false);
                }

                if (setting.FindDepend)
                {
                    FindAndAddAutoGroup(setting.IsShowProgressBar);
                }
                else
                {
                    DeleteAutoGroup();
                }
            }

            if (setting.ResetBundleName)
            {
                ClearAssetBundleNames(setting.IsShowProgressBar);
                SetAssetBundleNames(setting.IsShowProgressBar);
            }

            BundlePackConfig packConfig = Util.FileUtil.ReadFromBinary <BundlePackConfig>(BundlePackUtil.GetPackConfigPath());

            assetBundleManifest = PackAssetBundle(packConfig);

            return(true);
        }
Пример #2
0
        /// <summary>
        /// 移动文件
        /// </summary>
        void MoveFile(string bundlname)
        {
            BundlePackConfig m_PackConfig    = Util.FileUtil.ReadFromBinary <BundlePackConfig>(BundlePackUtil.GetPackConfigPath());
            string           outputTargetDir = m_PackConfig.OutputDirPath + "/" + m_PackConfig.GetBuildTarget().ToString() + "/" + AssetBundleConst.ASSETBUNDLE_MAINFEST_NAME + "_temp";

            //bund 文件
            string path  = string.Format("{0}/{1}", outPath_temp, bundlname);
            string path1 = string.Format("{0}/{1}", outPath_true, bundlname);

            if (File.Exists(path))
            {
                File.Delete(path1);
                File.Move(path, path1);
            }

            //bund manifest文件
            string path2 = string.Format("{0}/{1}.{2}", outPath_temp, bundlname, "manifest");
            string path3 = string.Format("{0}/{1}.{2}", outPath_true, bundlname, "manifest");

            if (File.Exists(path2))
            {
                File.Delete(path3);
                File.Move(path2, path3);
            }
        }
Пример #3
0
        internal BundlePackConfigGUI()
        {
            m_TargetContent           = new GUIContent("Build Target", "Choose target platform to build for.");
            m_CompressionContent      = new GUIContent("Compression", "Choose no compress, standard (LZMA), or chunk based (LZ4)");
            m_ForceRebuildContent     = new GUIContent("Force Rebuild", "Force rebuild the asset bundles");
            m_AppendHashContent       = new GUIContent("Append Hash", "Append the hash to the assetBundle name.");
            m_CleanBeforeBuildContent = new GUIContent("Clean Output Dir", "Delete the output dir before build");

            m_PackConfig     = Util.FileUtil.ReadFromBinary <BundlePackConfig>(BundlePackUtil.GetPackConfigPath());
            m_IsForceRebuild = m_PackConfig.BundleOptions.HasFlag(BuildAssetBundleOptions.ForceRebuildAssetBundle);
            m_IsAppendHash   = m_PackConfig.BundleOptions.HasFlag(BuildAssetBundleOptions.AppendHashToAssetBundleName);
        }
Пример #4
0
        /// <summary>
        /// 获得正在的输出路径
        /// </summary>
        /// <returns></returns>
        string GetTrueOutPath()
        {
            BundlePackConfig m_PackConfig = Util.FileUtil.ReadFromBinary <BundlePackConfig>(BundlePackUtil.GetPackConfigPath());

            options     = m_PackConfig.GetBundleOptions();
            buildTarget = m_PackConfig.GetBuildTarget();

            string outputTargetDir = m_PackConfig.OutputDirPath + "/" + buildTarget.ToString() + "/" + AssetBundleConst.ASSETBUNDLE_MAINFEST_NAME;

            if (!Directory.Exists(outputTargetDir))
            {
                Debug.LogError("eternity_assetbunles/StandaloneWindows64/assetbundles  -------> AB 存放路径不存在");
                return(string.Empty);
            }
            return(outputTargetDir);
        }
Пример #5
0
 /// <summary>
 /// 根据配置打包AB
 /// </summary>
 /// <param name="packConfig"></param>
 /// <returns></returns>
 public static AssetBundleManifest PackAssetBundle(BundlePackConfig packConfig)
 {
     return(PackAssetBundle(packConfig.OutputDirPath, packConfig.CleanupBeforeBuild, packConfig.GetBundleOptions(), packConfig.GetBuildTarget()));
 }