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)
|
| | | {
|
| | | 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)
|
| | | {
|
| | | 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)
|
| | | {
|
| | | 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)
|
| | | {
|
| | | ExcuteBuildAsset("config", buildParameters);
|
| | | }
|
| | | else
|
| | | {
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Debug.Log("打包配置表失败", buildParameters);
|
| | | Debug.Log(ex);
|
| | | EditorApplication.Exit(1);
|
| | | }
|
| | | } |
| | | |
| | | public static void BuildAudio()
|
| | | {
|
| | | try
|
| | | {
|
| | | var buildParameters = new BuildParameters();
|
| | | if (!buildParameters.error)
|
| | | {
|
| | | 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)
|
| | | {
|
| | | 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)
|
| | | {
|
| | | 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.outputPath, fileInfoes);
|
| | | AssetsVersionMaker.WriteAssetsVersionFile(buildParameters.outputPath, 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.outputPath, _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);
|
| | | }
|
| | | }
|
| | |
|
| | | } |
| | | |
| | | } |