private static string GetTargetDeviceFamily(iOSTargetDevice targetDevice) { if (targetDevice == iOSTargetDevice.iPhoneOnly) { return("1"); } if (targetDevice == iOSTargetDevice.iPadOnly) { return("2"); } return("1,2"); // universal }
public static void SetBuildParamFromCommandLineArgs() { string[] args = Environment.GetCommandLineArgs(); for (int i = 1, j = i + 1; j < args.Length; i++, j++) { string key = args[i]; string value = args[j]; if (value.StartsWith("-")) { continue; } switch (key) { case "-appName": { value = value.Replace("\"", ""); PlayerSettings.productName = value; //ResourceBuildTool.OutputLog("set product name: " + value); } break; case "-packageName": { PlayerSettings.applicationIdentifier = value; //ResourceBuildTool.OutputLog("set bundle identifier: " + value); } break; case "-targetDevice": { iOSTargetDevice target = (iOSTargetDevice)Enum.Parse(typeof(iOSTargetDevice), value); PlayerSettings.iOS.targetDevice = target; //ResourceBuildTool.OutputLog("set ios target device: iOSTargetDevice." + value); } break; case "-obb": { PlayerSettings.Android.useAPKExpansionFiles = true; //ResourceBuildTool.OutputLog("set android OBB."); } break; } } }
private static void Load2IOS() { companyName = Application.companyName; prodectName = Application.productName; qualityLevel = QualitySettings.GetQualityLevel(); isFullPack = PlayerPrefs.GetInt("PackManager_isFullPack", 0) == 1; targetPatch = PlayerPrefs.GetString("Editor_targetPatch", "../../" + @"\IOS\FishZoo\"); packName = PlayerSettings.GetApplicationIdentifier(buildTargetGroup); script = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS); targetOSVersion = PlayerSettings.iOS.targetOSVersionString; targetDevice = PlayerSettings.iOS.targetDevice; sdkVersion = PlayerSettings.iOS.sdkVersion; }
internal static void ApplySettings(iOSSdkVersion targetSDK = iOSSdkVersion.DeviceSDK, iOSTargetDevice targetDevice = iOSTargetDevice.iPhoneAndiPad, string targetOSVersionString = "8.0") { UnityEditor.PlayerSettings.iOS.sdkVersion = targetSDK; UnityEditor.PlayerSettings.iOS.targetDevice = targetDevice; UnityEditor.PlayerSettings.iOS.targetOSVersionString = targetOSVersionString; }
/// <summary> /// IOS部分对应显示 /// </summary> private void ShowIOS() { EditorGUILayout.BeginVertical(); prodectName = EditorGUILayout.TextField("项目名:", prodectName); packName = EditorGUILayout.TextField("包名:", packName); EditorGUILayout.LabelField("路径是否正确 : " + Directory.Exists(targetPatch)); targetPatch = EditorGUILayout.TextField("项目路径:", targetPatch); EditorGUILayout.LabelField("IOS设置:"); script = EditorGUILayout.TextField("项目注入:", script); targetOSVersion = EditorGUILayout.TextField("IOS版本支援:", targetOSVersion); sdkVersion = (iOSSdkVersion)EditorGUILayout.EnumPopup("目标SDK:", sdkVersion); targetDevice = (iOSTargetDevice)EditorGUILayout.EnumPopup("目标设备:", targetDevice); isFullPack = EditorGUILayout.Toggle("是否为完整导出:", isFullPack); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("读取")) { Load2IOS(); this.Repaint(); } if (GUILayout.Button("写入")) { Write2IOS(); } if (GUILayout.Button("打包(如有变更先写入)")) { var file = Build2IOS(); if (file.Length > 0) { if (EditorUtility.DisplayDialog("PackManager", "导出成功,是否导入IOS工程", "Yep", "Closs")) { if (isFullPack) { var left = targetPatch; var right = @"ForIOS\" + prodectName; try { if (Directory.Exists(left)) { Directory.Delete(left, true); } Directory.Move(right, left); if (Directory.Exists(right)) { Directory.Delete(right, true); } Directory.Delete("ForIOS", true); Assembly assembly = Assembly.GetAssembly(typeof(SceneView)); Type logEntries = assembly.GetType("UnityEditor.LogEntries"); MethodInfo clearConsoleMethod = logEntries.GetMethod("Clear"); clearConsoleMethod.Invoke(new object(), null); Debug.Log("打包完成!"); this.Close(); } catch (System.Exception e) { if (EditorUtility.DisplayDialog("PackManager", e.Message, "Closs")) { this.Close(); } } } else { var ass = targetPatch + @"\Classes"; var jl = targetPatch + @"\Data"; var lb = targetPatch + @"\Libraries"; var assnew = @"ForIOS\" + prodectName + @"\Classes"; var jlnew = @"ForIOS\" + prodectName + @"\Data"; var lbnew = @"ForIOS\" + prodectName + @"\Libraries"; try { if (Directory.Exists(ass) && Directory.Exists(jl) && Directory.Exists(lb)) { Directory.Delete(ass, true); Directory.Delete(jl, true); Directory.Delete(lb, true); } Directory.Move(assnew, ass); Directory.Move(jlnew, jl); Directory.Move(lbnew, lb); Directory.Delete("ForIOS", true); var file01 = ass + @"\UnityAppController.h"; var file02 = ass + @"\UnityAppController.mm"; if (File.Exists(file01) && File.Exists(file02)) { File.Delete(file01); File.Delete(file02); } Assembly assembly = Assembly.GetAssembly(typeof(SceneView)); Type logEntries = assembly.GetType("UnityEditor.LogEntries"); MethodInfo clearConsoleMethod = logEntries.GetMethod("Clear"); clearConsoleMethod.Invoke(new object(), null); Debug.Log("打包完成!"); this.Close(); } catch (System.Exception e) { if (EditorUtility.DisplayDialog("PackManager", e.Message, "Closs")) { this.Close(); } } } } else { this.Close(); } } } if (GUILayout.Button("关闭")) { this.Close(); } try { EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } catch (Exception) { Debug.Log("Why is always consle ?"); } }
static void PerformIOSBuildWithParameters() { string[] args = System.Environment.GetCommandLineArgs(); List <string> buildParameters = new List <string>(); for (int i = 0; i < args.Length; i++) { var a = args[i]; if (a.Equals("-executeMethod")) { for (int j = i + 1; j < args.Length; j++) { if (args[j].Contains("-")) { break; } buildParameters.Add(args[j]); } } } bool needDebug = false; iOSTargetDevice targetDevice = iOSTargetDevice.iPhoneAndiPad; foreach (var p in buildParameters) { if (p.Equals("Debug")) { needDebug = true; } else if (p.Equals("NoDebug")) { needDebug = false; } else if (p.Equals("Universal")) { targetDevice = iOSTargetDevice.iPhoneAndiPad; } else if (p.Equals("iPhone")) { targetDevice = iOSTargetDevice.iPhoneOnly; } else if (p.Equals("iPad")) { targetDevice = iOSTargetDevice.iPadOnly; } PlayerSettings.iOS.targetDevice = targetDevice; PlayerSettings.applicationIdentifier = PlayerSettings.applicationIdentifier.Replace(".hd", ""); if (targetDevice == iOSTargetDevice.iPadOnly) { PlayerSettings.applicationIdentifier = PlayerSettings.applicationIdentifier + ".hd"; } } BundlePrefixChecker.VerifyBundle(); PluginIDCreator.Instance.isDebug = needDebug; PluginIDCreator.Instance.isIPadOnly = targetDevice == iOSTargetDevice.iPadOnly; PluginIDCreator.Instance.Generate(); ActualPerformBuild(needDebug); }