单页面个人网站,wordpress rss订阅地址,品牌网站建设找顺的,建立网站和小程序需要多少钱目录(?)[-]核心代码自动化修改代码参考资料iPhoneX适配#xff0c;比较搓的一种方式#xff0c;在不修改分辨率#xff08;720 x 1280#xff09;的情况下适配iphone X 主屏尺寸#xff1a; 5.8英寸 主屏分辨率#xff1a; 2436 x 1125核心代码修改 工程目录/Classes/Un…目录(?)[-]核心代码自动化修改代码参考资料iPhoneX适配比较搓的一种方式在不修改分辨率720 x 1280的情况下适配iphone X 主屏尺寸 5.8英寸 主屏分辨率 2436 x 1125核心代码修改 工程目录/Classes/UnityAppController.mm 文件判断的方式比较搓以 iPhone X 的宽高的 与众不同来判断为了不调整分辨率的情况下适配这里是 竖屏 应用高度改为 150 是最好的值。横屏 应用修改 height 为 widthy为 x 即可找到方法代码// _window [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];CGRect winSize [UIScreen mainScreen].bounds;if (winSize.size.height / winSize.size.width 2) {winSize.size.height - 150;winSize.origin.y 75;::printf(- is iphonex hello world\n);} else {::printf(- is not iphonex hello world\n);}_window [[UIWindow alloc] initWithFrame: winSize];
123456789101112运行效果自动化修改代码不用每次打xcode后都需要手动修改参考https://www.cnblogs.com/pandawuwyj/p/6904770.html增加一个修改 文件的类using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;namespace UnityEditor.XCodeEditor
{public partial class XClassExt : System.IDisposable{private string filePath;public XClassExt(string fPath){filePath fPath;if (!System.IO.File.Exists(filePath)){Debug.LogError(filePath not found in path.);return;}}public void WriteBelow(string below, string text){StreamReader streamReader new StreamReader(filePath);string text_all streamReader.ReadToEnd();streamReader.Close();int beginIndex text_all.IndexOf(below);if (beginIndex -1){Debug.LogError(filePath not found sign in below);return;}int endIndex text_all.LastIndexOf(\n, beginIndex below.Length);text_all text_all.Substring(0, endIndex) \n text \n text_all.Substring(endIndex);StreamWriter streamWriter new StreamWriter(filePath);streamWriter.Write(text_all);streamWriter.Close();}public void Replace(string below, string newText){StreamReader streamReader new StreamReader(filePath);string text_all streamReader.ReadToEnd();streamReader.Close();int beginIndex text_all.IndexOf(below);if (beginIndex -1){Debug.LogError(filePath not found sign in below);return;}text_all text_all.Replace(below, newText);StreamWriter streamWriter new StreamWriter(filePath);streamWriter.Write(text_all);streamWriter.Close();}public void Dispose(){}}
}
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071打包后处理动态修改 xcode配置 及 文件内容using System;
using System.IO;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.Callbacks;#if UNITY_EDITOR_OSXusing UnityEditor.iOS.Xcode;
using UnityEditor.XCodeEditor;#endifpublic class Package {#if UNITY_EDITOR_OSX[PostProcessBuildAttribute(100)]public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject) {if (target ! BuildTarget.iOS) {Debugger.LogWarning(Target is not iPhone. XCodePostProcess will not run);return;}// Create a new project object from build targetPBXProject project new PBXProject();string configFilePath PBXProject.GetPBXProjectPath(pathToBuiltProject);project.ReadFromFile(configFilePath);string targetGuid project.TargetGuidByName(Unity-iPhone);string debug project.BuildConfigByName(targetGuid, Debug);string release project.BuildConfigByName(targetGuid, Release);project.AddBuildPropertyForConfig(debug, CODE_SIGN_RESOURCE_RULES_PATH, $(SDKROOT)/ResourceRules.plist);project.AddBuildPropertyForConfig(release, CODE_SIGN_RESOURCE_RULES_PATH, $(SDKROOT)/ResourceRules.plist);project.AddFrameworkToProject(targetGuid, SystemConfiguration.framework, true);project.AddFrameworkToProject(targetGuid, Security.framework, true);project.AddFrameworkToProject(targetGuid, libz.tbd, true);project.AddFrameworkToProject(targetGuid, libc.tbd, true);project.SetBuildProperty(targetGuid, ENABLE_BITCODE, NO);project.WriteToFile(configFilePath);EditSuitIpXCode(pathToBuiltProject);}public static void EditSuitIpXCode(string path) {//插入代码//读取UnityAppController.mm文件string src _window [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];;string dst // _window [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];CGRect winSize [UIScreen mainScreen].bounds;if (winSize.size.height / winSize.size.width 2) {winSize.size.height - 150;winSize.origin.y 75;::printf(- is iphonex aaa hello world\n);} else {::printf(- is not iphonex aaa hello world\n);}_window [[UIWindow alloc] initWithFrame: winSize];;string unityAppControllerPath path /Classes/UnityAppController.mm;XClassExt UnityAppController new XClassExt(unityAppControllerPath);UnityAppController.Replace(src, dst);}#endif}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475参考资料http://blog.csdn.net/nicepainkiller/article/details/78926077