public static void UnityBuildPlayer(List <string> scenesToBuild, BuildTarget buildTarget, BuildOptions buildOptions) { const string funcBlock = "AutoBuild.UnityBuildPlayer()"; BuildLogger.OpenBlock(funcBlock); BuildLogger.LogMessage("Scenes to build:"); foreach (string sceneName in scenesToBuild) { BuildLogger.LogMessage('\t' + sceneName); } BuildLogger.LogMessage("BuildTarget=" + buildTarget.ToString()); BuildLogger.LogMessage("BuildOptions=" + buildOptions.ToString()); if (buildTarget == BuildTarget.Android) { outDir = outDir + "/" + PlayerSettings.bundleIdentifier + ".apk"; } string buildPlayerBlock = string.Format("BuildPipeline.BuildPlayer (\"{0}\")", Path.GetFileName(outDir)); BuildLogger.OpenBlock(buildPlayerBlock); string errorMessage = BuildPipeline.BuildPlayer(scenesToBuild.ToArray(), outDir, buildTarget, buildOptions); BuildLogger.CloseBlock(buildPlayerBlock); if (errorMessage != null && !errorMessage.Equals("") && !(errorMessage.Length == 0)) { throw new ApplicationException(errorMessage); } BuildLogger.CloseBlock(funcBlock); }
static void GenericBuild(string[] scenes, string target, BuildTarget build_target, BuildOptions build_options) { if (build_target != EditorUserBuildSettings.activeBuildTarget) { throw new Exception("You need switch platform to " + build_target + " by your own, in case wrong operation."); } // Version number /*var gameVersion = CommandLineReader.GetCustomArgument("Game_Version").Trim(new [] {'\r', '\n'}); * if (string.IsNullOrEmpty(gameVersion)) * { #if !SERVER_BUILD * gameVersion = "0.0.1"; #else * throw new Exception("missing Game_Version in command line args"); #endif * } * PlayerSettings.bundleVersion = gameVersion;*/ Debug.Log("Start build " + build_target.ToString() + " with option " + build_options.ToString() + " to " + target); string res = BuildPipeline.BuildPlayer(scenes, target, build_target, build_options); if (res.Length > 0) { throw new Exception("BuildPlayer failure: " + res); } }
public static void BuildAndroid() { Debug.Log("android build start --------------------"); // 外部のビルド設定を適用 CreateBuildParam(); // Android側は元々『BuildOptionsの指定がNone』だったので、想定どおりに動けば問題ない BuildOptions options = batchBuildReplaceParam.CreateBuildOptions(); Debug.Log("---------------- BuildOptions :" + options.ToString()); Common(BuildTargetGroup.Android, androidBundle); PlayerSettings.Android.bundleVersionCode = buildVersion; //PlayerSettings.statusBarHidden = true; PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64 | AndroidArchitecture.ARMv7; #if SER || PUR || STR // ビルドセッティングの設定 PlayerSettings.statusBarHidden = true; // keystoreの指定。アプリに含めないようにEditorフォルダに入れてます。 //PlayerSettings.asset内に直指定 PlayerSettings.Android.keystoreName = Directory.GetCurrentDirectory() + "/KeyStore/.keystore"; // keystore作成時に設定したkestoreのパスワード PlayerSettings.Android.keystorePass = ""; //// keystore作成時に設定したalias名 PlayerSettings.Android.keyaliasName = ""; //// keystore作成時に設定したaliasのパスワード PlayerSettings.Android.keyaliasPass = ""; //Log SetStackTraceType(StackTraceLogType.None); #elif STG //Log SetStackTraceType(StackTraceLogType.None); #else //Log SetStackTraceType(StackTraceLogType.ScriptOnly); #endif if (!Directory.Exists("Build")) { Directory.CreateDirectory("Build"); } //本番と同時にイストアール出来るけと、pushか来ないになる //File.Delete("Assets/Plugins/Android/AndroidManifest.xml"); //本番と同時にイストアールできない、機能か正常になる //File.Delete("Assets/Plugins/Android/dev/AndroidManifest.xml"); var buildReport = BuildPipeline.BuildPlayer(GetScenes(), "Build/android.apk", BuildTarget.Android, options); CheckBuildSuccess(buildReport); Debug.Log("android build end --------------------"); }
public static void BuildiOS() { Debug.Log("iOS build start ------------------------"); // 外部のビルド設定を適用 CreateBuildParam(); BuildOptions opt = batchBuildReplaceParam.CreateBuildOptions(); Debug.Log("---------------- BuildOptions :" + opt.ToString()); // ビルドセッティングの設定 Common(BuildTargetGroup.iOS, iosBundle); PlayerSettings.SetArchitecture(BuildTargetGroup.iOS, 1); // 1 ARM64 2 Universal (ARMv7 or ARM64) EditorUserBuildSettings.iOSBuildConfigType = iOSBuildType.Release; // xcode上でのビルドオプション設定 PlayerSettings.iOS.buildNumber = buildVersion.ToString(); PlayerSettings.iOS.appleEnableAutomaticSigning = true; // こいつをonにしないと、jenkinsでbuildしたときに失敗する #if SER || PUR || STR // 本番は手動で行うのでoffにする PlayerSettings.iOS.appleEnableAutomaticSigning = false; //Log SetStackTraceType(StackTraceLogType.None); #else //Log SetStackTraceType(StackTraceLogType.ScriptOnly); #endif PlayerSettings.iOS.sdkVersion = iOSSdkVersion.DeviceSDK; PlayerSettings.iOS.targetOSVersionString = "11.0"; PlayerSettings.iOS.targetDevice = iOSTargetDevice.iPhoneAndiPad; PlayerSettings.statusBarHidden = true; PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait; if (!Directory.Exists("Build/Device")) { Directory.CreateDirectory("Build/Device"); } var buildReport = BuildPipeline.BuildPlayer(GetScenes(), "Build/Device", BuildTarget.iOS, opt); CheckBuildSuccess(buildReport); Debug.Log("iOS build end ------------------------"); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(String.Format("BuildMode:{0} \n", BuildMode)); sb.Append(String.Format("BuildTarget:{0} \n", BuildTarget)); sb.Append(String.Format("EnableHotFix:{0} \n", EnableHotFix)); sb.Append(String.Format("HotFixUrl:{0} \n", HotFixUrl)); sb.Append(String.Format("CopyFmod:{0} \n", CopyFmod)); sb.Append(String.Format("IncreativeBuildAssetBundles:{0} \n", IncreativeBuildAssetBundles)); sb.Append(String.Format("BundleCompress:{0} \n", BundleCompress)); sb.Append(String.Format("ApplyAllRule:{0} \n", ApplyAllRule)); sb.Append(String.Format("BuildVersion:{0} \n", BuildVersion)); sb.Append(String.Format("BuildOptions:{0} \n", BuildOptions.ToString())); sb.Append(String.Format("OutputPath:{0} \n", OutputPath)); sb.Append(String.Format("UseMono2X:{0} \n", UseMono2X)); sb.Append(String.Format("Multithreaded:{0} \n", Multithreaded)); sb.Append(String.Format("MacroDefines:{0} \n", MacroDefines)); sb.Append(String.Format("ExportProject:{0} \n", ExportProject)); sb.Append(String.Format("UseGradle:{0} \n", UseGradle)); sb.Append(String.Format("BundleIdentifier:{0} \n", BundleIdentifier)); return(sb.ToString()); }
static void GenericBuild(string[] scenes, string target, BuildTarget build_target, BuildOptions build_options) { #if !SERVER_BUILD if (build_target != EditorUserBuildSettings.activeBuildTarget) { throw new Exception("You need switch platform to " + build_target + " by your own, in case wrong operation."); } #endif // Version number var gameVersion = CommandLineReader.GetCustomArgument("Game_Version").Trim(new [] { '\r', '\n' }); if (string.IsNullOrEmpty(gameVersion)) { #if !SERVER_BUILD gameVersion = "0.0.1"; #else throw new Exception("missing Game_Version in command line args"); #endif } PlayerSettings.bundleVersion = gameVersion; string target_ = CommandLineReader.GetCustomArgument("Build_Target"); if (!String.IsNullOrEmpty(target_)) { target = target_; } string dir = target.Substring(0, target.LastIndexOf("/")); Directory.CreateDirectory(dir); Debug.Log("GenericBuild pre build."); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); MethodInfo[] methods = assemblies.SelectMany(a => a.GetTypes()) .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) .Where(m => m.GetCustomAttributes(typeof(PreBuildAttribute), false).Length > 0) .OrderBy(m => (m.GetCustomAttributes(typeof(PreBuildAttribute), false)[0] as PreBuildAttribute).callbackOrder) .ToArray(); if (methods.Length == 0) { throw new Exception("No PreBuild method found?"); } foreach (MethodInfo method in methods) { method.Invoke(null, new object[] { scenes, target, build_target, build_options }); } #if !RELEASE_VERSION build_options |= BuildOptions.ForceEnableAssertions; #endif string prjTarget = target; if (build_target == BuildTarget.Android) { build_options |= BuildOptions.AcceptExternalModificationsToPlayer; prjTarget += "_prj"; #if SDK_OBBDOWNLOADER PlayerSettings.Android.useAPKExpansionFiles = true; #endif } if (Directory.Exists(prjTarget)) { Directory.Delete(prjTarget, true); } Debug.Log("Start build " + build_target.ToString() + " with option " + build_options.ToString() + " to " + prjTarget); EditorUserBuildSettings.SwitchActiveBuildTarget(build_target); string res = BuildPipeline.BuildPlayer(scenes, prjTarget, build_target, build_options); if (res.Length > 0) { throw new Exception("BuildPlayer failure: " + res); } Debug.Log("GenericBuild post build."); assemblies = AppDomain.CurrentDomain.GetAssemblies(); methods = assemblies.SelectMany(a => a.GetTypes()) .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) .Where(m => m.GetCustomAttributes(typeof(PostBuildAttribute), false).Length > 0) .OrderBy(m => (m.GetCustomAttributes(typeof(PostBuildAttribute), false)[0] as PostBuildAttribute).callbackOrder) .ToArray(); if (methods.Length == 0) { throw new Exception("No PostBuild method found?"); } foreach (MethodInfo method in methods) { method.Invoke(null, new object[] { build_target, prjTarget, target }); } }