| using System.Collections; | 
| using System.Collections.Generic; | 
| using UnityEngine; | 
| using System; | 
| using UnityEditor; | 
|   | 
| public class ClientPackageExtension | 
| { | 
|   | 
|     public static void BuildApk() | 
|     { | 
|         var parameters = new BuildParameters(); | 
|   | 
|         if (!parameters.error) | 
|         { | 
|             try | 
|             { | 
|                 ClientPackage.AssetPrior = 1; | 
|                 ClientPackage.BuildPublishers(parameters.sdkPath, parameters.assetbundlePath, parameters.outputPath, parameters.publishers, parameters.buildIndex, false, false); | 
|             } | 
|             catch (Exception ex) | 
|             { | 
|                 Debug.Log("打包apk失败"); | 
|                 Debug.Log(ex); | 
|                 EditorApplication.Exit(1); | 
|             } | 
|         } | 
|         else | 
|         { | 
|             EditorApplication.Exit(1); | 
|         } | 
|   | 
|     } | 
|   | 
|     public static void BuildEXE() | 
|     { | 
|         var parameters = new BuildParameters(); | 
|         if (!parameters.error) | 
|         { | 
|             try | 
|             { | 
|                 ClientPackage_Standalone.AssetPrior = 1; | 
|                 ClientPackage_Standalone.Build(new ClientPackage_Standalone.BuildParams() | 
|                 { | 
|                     assetBundle = parameters.assetbundlePath, | 
|                     output = parameters.outputPath, | 
|                     buildIndex = parameters.buildIndex, | 
|                     development = false, | 
|                     publisher = parameters.publishers, | 
|                 }); | 
|             } | 
|             catch (Exception ex) | 
|             { | 
|                 Debug.Log("打包EXE失败"); | 
|                 Debug.Log(ex); | 
|                 EditorApplication.Exit(1); | 
|             } | 
|         } | 
|         else | 
|         { | 
|             EditorApplication.Exit(1); | 
|         } | 
|     } | 
|   | 
|     class BuildParameters | 
|     { | 
|         public bool error = false; | 
|         public string assetbundlePath; | 
|         public string outputPath; | 
|         public string publishers; | 
|         public int buildIndex; | 
|         public string sdkPath; | 
|   | 
|         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() == "-assetbundlepath") | 
|                     { | 
|                         assetbundlePath = args[i + 1]; | 
|                     } | 
|                     else if (arg.ToLower() == "-publishers") | 
|                     { | 
|                         publishers = args[i + 1]; | 
|                     } | 
|                     else if (arg.ToLower() == "-buildindex") | 
|                     { | 
|                         int.TryParse(args[i + 1], out buildIndex); | 
|                     } | 
|                     else if (arg.ToLower() == "-sdkpath") | 
|                     { | 
|                         sdkPath = args[i + 1]; | 
|                     } | 
|                 } | 
|   | 
|                 error = false; | 
|             } | 
|             catch (Exception ex) | 
|             { | 
|                 error = true; | 
|                 Debug.LogException(ex); | 
|                 EditorApplication.Exit(1); | 
|             } | 
|         } | 
|     } | 
|   | 
| } |