New file |
| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEditor; |
| | | using System.IO; |
| | | using System; |
| | | |
| | | public class BuildExtersion
|
| | | { |
| | | |
| | | public static void BuildMap()
|
| | | {
|
| | | try
|
| | | {
|
| | | var buildParameters = new BuildParameters();
|
| | | if (!buildParameters.error)
|
| | | {
|
| | | UpdateLevelSetting.SetAllLevelAssetBundleName();
|
| | | ExcuteBuildAsset("maps", buildParameters);
|
| | | }
|
| | | else
|
| | | {
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Debug.Log("打包地图失败");
|
| | | Debug.Log(ex);
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | |
|
| | | public static void BuildEffect()
|
| | | {
|
| | | try
|
| | | {
|
| | | var buildParameters = new BuildParameters();
|
| | | if (!buildParameters.error)
|
| | | {
|
| | | UpdateEffectPrefabSetting.SetAllEffectPrefabAssetBundleName();
|
| | | ExcuteBuildAsset("effect", buildParameters);
|
| | | }
|
| | | else
|
| | | {
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Debug.Log("打包特效失败");
|
| | | Debug.Log(ex);
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | |
|
| | | public static void BuildMob()
|
| | | {
|
| | | try
|
| | | {
|
| | | var buildParameters = new BuildParameters();
|
| | | if (!buildParameters.error)
|
| | | {
|
| | | UpdateMobSetting.SetAllMobAssetBundleName();
|
| | | ExcuteBuildAsset("mob", buildParameters);
|
| | | }
|
| | | else
|
| | | {
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Debug.Log("打包NPC模型失败");
|
| | | Debug.Log(ex);
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | } |
| | | |
| | | public static void BuildConfig()
|
| | | {
|
| | | try
|
| | | {
|
| | | var buildParameters = new BuildParameters();
|
| | | if (!buildParameters.error)
|
| | | {
|
| | | UpdateScriptableObjectsSetting.SetAllScriptableObjectAssetBundleName();
|
| | | ExcuteBuildAsset("config", buildParameters);
|
| | | TableTool.ReadAllTxtToBytes(StringUtility.Contact(buildParameters.GetWholeOutPutPath(), "/config"));
|
| | | }
|
| | | else
|
| | | {
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Debug.Log("打包配置表失败");
|
| | | Debug.Log(ex);
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | } |
| | | |
| | | public static void BuildAudio()
|
| | | {
|
| | | try
|
| | | {
|
| | | var buildParameters = new BuildParameters();
|
| | | if (!buildParameters.error)
|
| | | {
|
| | | UpdateAudioSetting.SetAllAudioAssetBundleName();
|
| | | ExcuteBuildAsset("audio", buildParameters);
|
| | | }
|
| | | else
|
| | | {
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Debug.Log("打包音效失败");
|
| | | Debug.Log(ex);
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | } |
| | | |
| | | public static void BuildShader()
|
| | | {
|
| | | try
|
| | | {
|
| | | var buildParameters = new BuildParameters();
|
| | | if (!buildParameters.error)
|
| | | {
|
| | | UpdateShaderSetting.SetAllShaderAssetBundleName();
|
| | | ExcuteBuildAsset("graphic", buildParameters);
|
| | | }
|
| | | else
|
| | | {
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Debug.Log("打包shader失败");
|
| | | Debug.Log(ex);
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | } |
| | | |
| | | public static void BuildUI()
|
| | | {
|
| | | try
|
| | | {
|
| | | var buildParameters = new BuildParameters();
|
| | | if (!buildParameters.error)
|
| | | {
|
| | | UpdateUIPrefabSetting.SetAllUIPrefabAssetBundleName();
|
| | | UpdateUIWindowSetting.SetAllUIWindowAssetBundleName();
|
| | | UpdateSpriteSetting.SetAllSpriteAssetBundleName();
|
| | |
|
| | | ExcuteBuildAsset("ui", buildParameters);
|
| | | }
|
| | | else
|
| | | {
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Debug.Log("打包ui失败");
|
| | | Debug.Log(ex);
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | |
|
| | | public static void MakeAssetVersionFile()
|
| | | {
|
| | | try
|
| | | {
|
| | | var buildParameters = new BuildParameters();
|
| | | if (buildParameters.error)
|
| | | {
|
| | | var fileInfoes = new List<FileInfo>();
|
| | | FileExtersion.GetAllDirectoryFileInfos(buildParameters.GetWholeOutPutPath(), fileInfoes);
|
| | | AssetsVersionMaker.WriteAssetsVersionFile(buildParameters.GetWholeOutPutPath(), fileInfoes);
|
| | | }
|
| | | else
|
| | | {
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Debug.Log("生成AssetVersion失败");
|
| | | Debug.Log(ex);
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | } |
| | | |
| | | private static void ExcuteBuildAsset(string _category, BuildParameters _params)
|
| | | {
|
| | | var opt = BuildAssetBundleOptions.None;
|
| | | opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
| | | opt |= BuildAssetBundleOptions.DeterministicAssetBundle;
|
| | |
|
| | | AssetBundleBuildExtersion.Build(_params.GetWholeOutPutPath(), _category, opt, _params.buildTarget);
|
| | | }
|
| | |
|
| | | class BuildParameters
|
| | | {
|
| | | public bool error = false;
|
| | | public string outputPath;
|
| | | public BuildTarget buildTarget;
|
| | |
|
| | | public BuildParameters()
|
| | | {
|
| | | try
|
| | | {
|
| | | var args = Environment.GetCommandLineArgs();
|
| | | for (int i = 0; i < args.Length; i++)
|
| | | {
|
| | | var arg = args[i];
|
| | | if (arg.ToLower() == "-outputpath")
|
| | | {
|
| | | outputPath = args[i + 1];
|
| | | }
|
| | | else if (arg.ToLower() == "-buildtarget")
|
| | | {
|
| | | switch (args[i + 1].ToLower())
|
| | | {
|
| | | case "android":
|
| | | buildTarget = BuildTarget.Android;
|
| | | break;
|
| | | case "ios":
|
| | | buildTarget = BuildTarget.iOS;
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | error = false;
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | error = true;
|
| | | Debug.LogException(ex);
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | |
|
| | | public string GetWholeOutPutPath()
|
| | | {
|
| | | return StringUtility.Contact(outputPath, "/", buildTarget.ToString().ToLower());
|
| | | }
|
| | | } |
| | | |
| | | } |