/// <summary> /// 打包AssetBundle /// </summary> void BuildingAssetBundle(emBuildType build_type) { try { bool running = true; SaveData(); running = AssetBundleNameTool.RunningAssetBundleNameTool(asset_bundle_build_); if (running) { running = SceneConfigTool.GenerateAllSceneConfig(asset_bundle_build_.Data.Scenes); } if (running) { BuildAssetBundle.BuildAllAssetBundlesToTarget(GetBuildTargetType(build_type), build_option_); } if (running) { LoadAssetBundleGranularityInfo(); } } catch (System.Exception ex) { Debug.LogError(ex.Message); } SceneConfigTool.RestoreAllScene(asset_bundle_build_.Data.Scenes); EditorUtility.ClearProgressBar(); }
/// <summary> /// 生成所有场景配置文件 /// </summary> public static bool GenerateAllSceneConfig(AssetBundleBuildData.SceneBuild scene_rules) { RecordDefaultOpenScene(); bool cancel = false; float total = (float)scene_rules.Scenes.Count; float current = 0; for (int i = 0; i < scene_rules.Scenes.Count; ++i) { var scene = scene_rules.Scenes[i].ScenePath; if (scene_rules.Scenes[i].IsBuild) { CopySceneToBackup(scene); GenerateSceneConfig(scene); AssetBundleNameTool.SetAssetBundleName(SceneConfig.GetSceneConfigPath(scene)); AssetBundleNameTool.SetAssetBundleName(scene); } else { DeleteSceneConfig(scene); AssetBundleNameTool.ClearAssetBundleName(scene); } current += 1.0f; float progress = current / total; if (EditorUtility.DisplayCancelableProgressBar("正在生成场景配置数据", "Change " + scene, progress)) { cancel = true; break; } } EditorUtility.ClearProgressBar(); return(!cancel); }
/// <summary> /// /// </summary> void DrawGeneral() { GUILayout.BeginVertical(GUI.skin.FindStyle("flow background"), GUILayout.MaxHeight(80f)); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("输出位置", EditorCommon.BUILD_PATH); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); build_option_ = (BuildAssetBundleOptions)EditorGUILayout.EnumPopup("打包选项", build_option_, GUILayout.MinWidth(200f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(20f); bool is_save_data = GUILayout.Button("仅保存规则文件(" + AssetBundleBuild.FILE_FULL_NAME + ")"); GUILayout.Space(20f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(20f); bool is_running_ab_name_tool = GUILayout.Button("仅生成资源AssetBundleName"); GUILayout.Space(20f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(20f); bool is_build_win = GUILayout.Button("Windows平台版本 - 打包"); GUILayout.Space(20f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(20f); bool is_build_android = GUILayout.Button(" Android平台版本 - 打包"); GUILayout.Space(20f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(20f); bool is_build_ios = GUILayout.Button(" IOS平台版本 - 打包"); GUILayout.Space(20f); GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (is_save_data) { SaveData(); } if (is_running_ab_name_tool) { AssetBundleNameTool.RunningAssetBundleNameTool(asset_bundle_build_); } if (is_build_win) { BuildingAssetBundle(emBuildType.StandaloneWindows); } else if (is_build_android) { BuildingAssetBundle(emBuildType.Android); } else if (is_build_ios) { BuildingAssetBundle(emBuildType.IOS); } }
static void ClearSelectionAssetBundleName() { AssetBundleNameTool.ClearSelectionAssetBundleName(); }
static void SetSelectionAssetBundleName() { AssetBundleNameTool.SetSelectionAssetBundleName(); }