/// <summary> /// 打AB后的回调 /// </summary> public static void OnAfterBuildAB(BuildParams buildParam) { if (onAfterBuildAB != null) { onAfterBuildAB(buildParam); } }
private static void BuildXCodeProject(BuildParams param) { #if UNITY_EDITOR_OSX if (param.target != BuildTarget.iOS) { return; } var xcodeprojPath = Application.dataPath + "/../xgame/Unity-iPhone.xcodeproj"; var projPath = xcodeprojPath + "/project.pbxproj"; if (!File.Exists(projPath)) { BuildLog.LogError("xcode project path ERROR:" + projPath); return; } PBXProject proj = new PBXProject(); proj.ReadFromFile(projPath); BuildLog.Log("open xcode project:" + proj); var target = proj.GetUnityMainTargetGuid(); File.WriteAllText(projPath, proj.WriteToString()); var askForBuildLocation = false; EditorUserBuildSettings.selectedBuildTargetGroup = BuildTargetGroup.iOS; BuildHelper.RefectionInvoke(BuildHelper.EditorAssembly, "UnityEditor.BuildPlayerWindow", "BuildPlayerAndRun", null, new Type[] { typeof(bool) }, new object[] { askForBuildLocation }); #endif }
/// <summary> /// 打AB前的回调 /// </summary> public static void OnBeforeBuildAB(BuildParams buildParam) { if (onBeforeBuildAB != null) { onBeforeBuildAB(buildParam); } }
public static void BuildOSXAB() { if (s_Param == null) { s_Param = GetBuildParamsByCommandArgs(BuildTarget.StandaloneWindows); } BuildAB(BuildTarget.StandaloneOSX, s_Param); }
public static void BuildWindow() { if (s_Param == null) { s_Param = GetBuildParamsByCommandArgs(BuildTarget.StandaloneWindows); } Debug.LogError(s_Param); }
/// <summary> /// 打包体后的回调 /// </summary> public static void OnAfterBuildPackage(BuildParams buildParam, bool success) { SceneTool.RefreshSettingList(false); if (onAfterBuildPackage != null) { onAfterBuildPackage(buildParam); } }
/// <summary> /// 打包体前的回调 /// </summary> public static void OnBeforeBuildPackage(BuildParams buildParam) { if (onBeforeBuildPackage != null) { onBeforeBuildPackage(buildParam); } SceneTool.RefreshSettingList(true); EditorSceneManager.OpenScene(buildParam.startScene); }
public static BuildParams Parse(string strParams) { var param = new BuildParams(); if (string.IsNullOrEmpty(strParams)) { return(param); } if (!regex.IsMatch(strParams)) { return(param); } strParams = strParams.Replace('{', ' '); strParams = strParams.Replace('}', ' '); var alls = strParams.Split(','); foreach (var str in alls) { var subs = str.Split(new char[] { '=', ':' }); if (subs == null || subs.Length != 2) { continue; } var key = subs[0].Trim(); var value = subs[1].Trim(); if (key.Equals("productName")) { param.productName = value; } else if (key.Equals("apkVersion")) { param.apkVersion = value; } else if (key.Equals("resVersion")) { param.resVersion = value; } else if (key.Equals("applicationIdentifier")) { param.resVersion = value; } else if (key.Equals("bundleVersionCode")) { param.bundleVersionCode = ParseInt(value); } else if (key.Equals("isDebug")) { param.isDebug = ParseBool(value); } else if (key.Equals("appleDeveloperTeamID")) { param.appleDeveloperTeamID = value; } } return(param); }
private static void BuildAB(BuildTarget target, BuildParams param) { var abDir = "Res_AB/" + target; var abPath = Application.dataPath + "/../" + abDir; var option = BuildAssetBundleOptions.None; option |= BuildAssetBundleOptions.ChunkBasedCompression; BuildHelper.CreateDir(abPath); BuildPipeline.BuildAssetBundles(abDir, option, target); }
private static void BuildAB(BuildParams param, bool onlyBuildAB) { var abDir = BuildHelper.GetABDir(param.target); var abPath = BuildHelper.GetABDirPath(param.target); var option = BuildAssetBundleOptions.None; option |= BuildAssetBundleOptions.ChunkBasedCompression; BuildHelper.CreateDir(abPath); BuildPipeline.BuildAssetBundles(abDir, option, param.target); BuildLog.Log("BuildAB DONE!"); }
private static void BuildPackage(BuildParams param) { BuildRegister.OnBeforeBuildPackage(param); var flag = BuildPlayer(param); BuildRegister.OnAfterBuildPackage(param, flag); if (flag) { BuildXCodeProject(param); } }
private static void InitBuildParams(BuildTarget target) { if (s_Param == null) { s_Param = BuildHelper.GetBuildParamsFromCommandLine(target); BuildLog.Log("BuildParams:" + s_Param); } else { s_Param.target = target; } }
private static BuildParams GetBuildParamsByCommandArgs(BuildTarget target) { BuildParams param; var args = Environment.GetCommandLineArgs(); if (Application.isBatchMode && args != null && args.Length >= 10) { var strParams = args[9]; param = BuildParams.Parse(strParams); } else { param = new BuildParams(); } return(param); }
private static bool BuildPlayer(BuildParams param) { var sourAbPath = BuildHelper.GetABDirPath(param.target); var destAbPath = Application.streamingAssetsPath; if (!Directory.Exists(sourAbPath)) { BuildLog.LogError("ab path not exists:" + sourAbPath); return(false); } BuildHelper.ClearDir(destAbPath); BuildHelper.CopyDir(sourAbPath, destAbPath, ".manifest|.meta"); PlayerSettings.productName = param.productName; PlayerSettings.companyName = param.companyName; PlayerSettings.applicationIdentifier = param.applicationIdentifier; PlayerSettings.bundleVersion = param.version; PlayerSettings.Android.bundleVersionCode = param.GetVersionCode(); PlayerSettings.iOS.buildNumber = param.GetVersionCode().ToString(); PlayerSettings.iOS.appleEnableAutomaticSigning = true; PlayerSettings.iOS.appleDeveloperTeamID = param.appleDeveloperTeamID; BuildPlayerOptions op = new BuildPlayerOptions(); op.scenes = new[] { param.startScene }; op.locationPathName = param.GetLocationPathName(); op.target = param.target; op.options = param.isDebug ? (BuildOptions.Development | BuildOptions.AllowDebugging | BuildOptions.ConnectWithProfiler) : BuildOptions.None; var result = BuildPipeline.BuildPlayer(op); var summary = result.summary; if (summary.result == BuildResult.Succeeded) { } if (summary.result == BuildResult.Failed) { return(false); } return(true); }
private static void BuildPlayer(BuildTarget target, BuildParams param) { PlayerSettings.productName = param.productName; PlayerSettings.applicationIdentifier = param.applicationIdentifier; PlayerSettings.bundleVersion = param.apkVersion; PlayerSettings.Android.bundleVersionCode = param.bundleVersionCode; PlayerSettings.iOS.buildNumber = param.bundleVersionCode.ToString(); PlayerSettings.iOS.appleEnableAutomaticSigning = true; PlayerSettings.iOS.appleDeveloperTeamID = param.appleDeveloperTeamID; BuildPlayerOptions op = new BuildPlayerOptions(); op.scenes = new[] { param.startScene }; op.target = target; op.options = param.isDebug ? (BuildOptions.Development | BuildOptions.AllowDebugging | BuildOptions.ConnectWithProfiler) : BuildOptions.None; var result = BuildPipeline.BuildPlayer(op); var summary = result.summary; }