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);
        }
        /// <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);
        }
Beispiel #3
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);
            }
        }
Beispiel #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);
        }
        internal void LayoutGUI()
        {
            var centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label"));

            centeredStyle.alignment = TextAnchor.UpperCenter;
            GUILayout.Label(new GUIContent("Bundle Pack Config"), centeredStyle);

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical();
            {
                m_PackConfig.OutputDirPath = EditorGUILayoutUtil.DrawDiskFolderSelection("Bundle Output", m_PackConfig.OutputDirPath);
                if (string.IsNullOrEmpty(m_PackConfig.OutputDirPath))
                {
                    m_PackConfig.OutputDirPath = GetDefaultOutputDir();
                }
                m_PackConfig.BuildTarget = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_PackConfig.BuildTarget);

                m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings");
                if (m_AdvancedSettings)
                {
                    EditorGUIUtil.BeginIndent();
                    {
                        m_PackConfig.CleanupBeforeBuild = EditorGUILayout.Toggle(m_CleanBeforeBuildContent, m_PackConfig.CleanupBeforeBuild);
                        m_PackConfig.Compression        = (CompressOptions)EditorGUILayout.IntPopup(m_CompressionContent, (int)m_PackConfig.Compression, m_CompressionContents, m_CompressionValues);

                        EditorGUILayout.Space();

                        EditorGUI.BeginChangeCheck();
                        {
                            m_IsForceRebuild = EditorGUILayout.Toggle(m_ForceRebuildContent, m_IsForceRebuild);
                            m_IsAppendHash   = EditorGUILayout.Toggle(m_AppendHashContent, m_IsAppendHash);
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (m_IsForceRebuild)
                            {
                                m_PackConfig.BundleOptions |= BuildAssetBundleOptions.ForceRebuildAssetBundle;
                            }
                            else
                            {
                                m_PackConfig.BundleOptions &= ~BuildAssetBundleOptions.ForceRebuildAssetBundle;
                            }
                            if (m_IsAppendHash)
                            {
                                m_PackConfig.BundleOptions |= BuildAssetBundleOptions.AppendHashToAssetBundleName;
                            }
                            else
                            {
                                m_PackConfig.BundleOptions &= ~BuildAssetBundleOptions.AppendHashToAssetBundleName;
                            }
                        }
                    }
                    EditorGUIUtil.EndIndent();
                }

                EditorGUILayout.Space();
                if (GUILayout.Button("Pack Bundle"))
                {
                    EditorApplication.delayCall += () =>
                    {
                        BundlePackUtil.PackAssetBundle(m_PackConfig);
                    };
                }
            }
            EditorGUILayout.EndVertical();


            if (GUI.changed)
            {
                Util.FileUtil.SaveToBinary <BundlePackConfig>(BundlePackUtil.GetPackConfigPath(), m_PackConfig);
            }
        }