/// <summary> /// 编辑代码文件 /// </summary> /// <param name="filePath"></param> private static void EditorCode(string filePath) { //读取UnityAppController.mm文件 XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); //在指定代码后面增加一行代码 //此方法在某一时刻才生效(2.0 < iOS Version < 9.0) UnityAppController.WriteBelow("@synthesize interfaceOrientation = _curOrientation;", "- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{[[IapppayKit sharedInstance] handleOpenUrl:url];return YES;}"); //此方法在某一时刻才生效(iOS Version > 9.0) UnityAppController.WriteBelow("@synthesize renderDelegate = _renderDelegate;", "- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options{[[IapppayKit sharedInstance] handleOpenUrl:url];return YES;}"); UnityAppController.WriteBelow("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);", "[[IapppayKit sharedInstance] handleOpenUrl:url];"); //声明头文件 UnityAppController.WriteBelow("#import <OpenGLES/ES2/glext.h>", "#import <IapppayKit/IapppayKit.h>"); //在指定代码中替换一行 //UnityAppController.Replace(@"return YES;",codeAdd2); }
private static void EditorCode(string filePath) { XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#include <apollo/ApolloApplication.h>"); UnityAppController.WriteBelow("UnityCleanup();\n", " [[ApolloApplication sharedInstance] applicationWillTerminate:application];"); UnityAppController.WriteBelow("- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation\n{", " [[ApolloApplication sharedInstance] handleOpenURL:url];"); if (isV5() == true) { UnityAppController.WriteBelow("::printf(\"-> applicationWillEnterForeground()\\n\");", " [[ApolloApplication sharedInstance] applicationWillEnterForeground:application];"); UnityAppController.WriteBelow("::printf(\"-> applicationWillResignActive()\\n\");", " [[ApolloApplication sharedInstance] applicationWillResignActive:application];"); UnityAppController.WriteBelow("::printf(\"-> applicationDidEnterBackground()\\n\");", " [[ApolloApplication sharedInstance] applicationDidEnterBackground:application];"); UnityAppController.WriteBelow("::printf(\"-> applicationDidBecomeActive()\\n\");", " [[ApolloApplication sharedInstance] applicationDidBecomeActive:application];"); UnityAppController.WriteBelow("::printf(\"-> applicationWillTerminate()\\n\");", " [[ApolloApplication sharedInstance] applicationWillTerminate:application];"); UnityAppController.WriteBelow("\treturn YES;\n}", "- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\r{\r return [[ApolloApplication sharedInstance] handleOpenURL:url];\r} \n\n"); UnityAppController.WriteBelow("[[NSNotificationCenter defaultCenter] postNotificationName:name object:UnityGetGLViewController()];\n", "\r[[ApolloApplication sharedInstance]setRootVC:UnityGetGLViewController()];"); } else { UnityAppController.WriteBelow("printf_console(\"-> applicationWillEnterForeground()\\n\");", " [[ApolloApplication sharedInstance] applicationWillEnterForeground:application];"); UnityAppController.WriteBelow("printf_console(\"-> applicationWillResignActive()\\n\");", " [[ApolloApplication sharedInstance] applicationWillResignActive:application];"); UnityAppController.WriteBelow("UnityInitApplicationNoGraphics([[[NSBundle mainBundle] bundlePath]UTF8String]);\n", " [[ApolloApplication sharedInstance] setRootVC:UnityGetGLViewController()];"); UnityAppController.WriteBelow("[[ApolloApplication sharedInstance] applicationWillTerminate:application];\n\n}", "- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\r{\r return [[ApolloApplication sharedInstance] handleOpenURL:url];\r}"); } }
//修改oc代码 private static void ReviseClass() { string path = Path.Combine(System.Environment.CurrentDirectory, "iOSAdd/Files/HwAdsInterface.m"); XClass hwAdsInterface = new XClass(path); hwAdsInterface.Replace("call(\"555555555\")", "call(\"66666666\")"); }
bool GenerateClass(string genericClassName) { XClass xclass = new XClass(); Chilkat.Log log = new Chilkat.Log(); if (!xclass.LoadClass(genericClassName, log)) { return(false); } // Skip some classes we don't want.. if (xclass.DnEventArgs) { return(true); } if (xclass.Deprecated) { return(true); } // Generate the wrapper for this class to a StringBuilder, and then // write the contents of the StringBuilder to a file. StringBuilder sbSourceFile = new StringBuilder(); if (!generateClassToSb(xclass, sbSourceFile, log)) { return(false); } GenBase.writeFileIfModified(AppDataDir.BaseDir + "/sampleOutput/Ruby/" + ChilkatApi.GenBase.m_generateForMicroVersion + "/" + genericClassName + ".rb", sbSourceFile.ToString()); return(true); }
/* * filt path */ /* * private string filtPath (string path, Mod mod) * { * string tmp = null ; * string modPath = mod.path; * string projectpath = rootPath; * if (path.Contains ("${conf}")) * { * tmp = path.Replace ("${conf}", modPath); * } * if (path.Contains ("${project}")) * { * tmp = path.Replace ("${project}", projectpath); * } * Debug.Log ("path= " + path); * return tmp; * } */ /* * 通过XmlDocument处理后的Manifest会给每一个元素显示的使用命名空间, * 段:这样极其不美观 * 所以用一个方法去掉它们 * (用字符串的方式) */ private void BeBeautiful(string xml) { XmlDocument tmpXml = new XmlDocument(); tmpXml.Load(xml); string str1 = tmpXml.DocumentElement.Attributes ["android:versionName"].Value; string str2 = tmpXml.DocumentElement.Attributes ["android:versionCode"].Value; string str3 = tmpXml.DocumentElement.Attributes ["android:installLocation"].Value; tmpXml.DocumentElement.RemoveAttribute("android:versionName"); tmpXml.DocumentElement.RemoveAttribute("android:versionCode"); tmpXml.DocumentElement.RemoveAttribute("android:installLocation"); tmpXml.DocumentElement.SetAttribute("xmlns:android", "temp233333"); tmpXml.Save(xml); XClass xc = new XClass(xml); xc.Replace("xmlns:android=\"http://schemas.android.com/apk/res/android\"", ""); xc.Replace("temp233333", "http://schemas.android.com/apk/res/android"); XmlDocument newxml = new XmlDocument(); newxml.Load(xml); newxml.DocumentElement.SetAttribute("versionName", str1); newxml.DocumentElement.SetAttribute("versionCode", str2); newxml.DocumentElement.SetAttribute("installLocation", str3); newxml.Save(xml); xc.Replace("versionName", "android:versionName"); xc.Replace("versionCode", "android:versionCode"); xc.Replace("installLocation", "android:installLocation"); }
/// <summary> /// 编辑代码 /// </summary> /// <param name="filePath">File path.</param> private static void EditorCode(string filePath) { XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); WriteBasic(UnityAppController); WriteTerminate(UnityAppController); }
bool generateMethod(XMethod xmethod, XClass xclass, StringBuilder sbOut, Chilkat.Log log, bool lowerCaseAlt = false) { sbOut.Append("\r\n\t\t# Method: " + xmethod.EntryName + "\r\n\t\t#\r\n"); // lets add description... IEnumerable <string> chunked = chunkSplit(xmethod.Descrip, 100); foreach (var chunk in chunked) { sbOut.Append("\t\t# " + chunk.Trim().Replace("#\t\t", "# ") + "\r\n"); } sbOut.Append("\t\t#\r\n"); sbOut.Replace("=\r\n\t\t# _", " _"); //if (xmethod.Deprecated) // sbOut.Append("\t\t# This method has been deprecated. Do not use it.\r\n"); //sbOut.Append("\t\t# ==== Attributes\r\n\t\t#\r\n"); if (!genMethodSignature(xmethod, xclass, sbOut, log, lowerCaseAlt)) { return(false); } //sbOut.Append("\t\t\t{\r\n"); // Generate the method body here. This would include whatever code is necessary to prep input args, // make the call to the Chilkat API, and return the result.. sbOut.Append("\t\t\t# ...\r\n"); sbOut.Append("\t\tend\r\n\r\n"); if (!lowerCaseAlt && xmethod.ToLowerCaseStringMethod() != null) { generateMethod(xmethod, xclass, sbOut, log, true); } return(true); }
bool GenerateClass(string genericClassName) { XClass xclass = new XClass(); Chilkat.Log log = new Chilkat.Log(); if (!xclass.LoadClass(genericClassName, log)) { return(false); } // Skip some classes we don't want.. if (xclass.DnEventArgs) { return(true); } if (xclass.Deprecated) { return(true); } // Generate the wrapper for this class to a StringBuilder, and then // write the contents of the StringBuilder to a file. StringBuilder sbSourceFile = new StringBuilder(); if (!generateClassToSb(xclass, sbSourceFile, log)) { return(false); } GenBase.writeFileIfModified(txtOutputDir.Text + genericClassName + ".au3", sbSourceFile.ToString()); return(true); }
// www url 缓存 public static void EditWWWCacheCode(string path) { //插入代码 XClass UnityAppController = new XClass(path + "/Classes/Unity/WWWConnection.mm"); UnityAppController.WriteBelow("[request setAllHTTPHeaderFields: headers];", "request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;\n [request setHTTPShouldHandleCookies:NO];"); }
private static void EditorCode(string filePath) { //读取UnityAppController.mm文件 XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); //SDK_JYIOS //在指定代码后面增加一行代码 // UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"","#import <NdComPlatform/NdComPlatform.h>"); // //在指定代码后面增加一行 // UnityAppController.WriteBelow("- (void)applicationDidEnterBackground:(UIApplication *)application\n{","[[NdComPlatform defaultPlatform] NdPause];\n"); //SDK_TONGBU // have no EditorCode //SDK_XY // UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"","#import <XYPlatform/XYPlatform.h>"); // UnityAppController.WriteBelow ("- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions\n{","[XYPlatform defaultPlatform];"); // UnityAppController.WriteBelow ("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);","[[XYPlatform defaultPlatform] XYHandleOpenURL:url];\n"); // UnityAppController.WriteBelow ("- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window\n{","[[XYPlatform defaultPlatform] application:application supportedInterfaceOrientationsForWindow:window];\n"); // UnityAppController.WriteBelow ("UnitySendRemoteNotificationError(error);\n}","-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\n{\n[[XYPlatform defaultPlatform] XYHandleOpenURL:url];\nreturn YES;\n}"); //SDK_ZSY // UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"","#import <Cmge/Cmge.h>\n#import \"ZSYSDKTools.h\""); // UnityAppController.WriteBelow ("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);","[[CmgePlatform defaultPlatform] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];\n"); // UnityAppController.WriteBelow ("UnityInitApplicationNoGraphics([[[NSBundle mainBundle] bundlePath]UTF8String]);","[[ZSYSDKTools alloc] ZSYInit:launchOptions];"); //SDK_HM // UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"","#import <IPAYiAppPay.h>"); // UnityAppController.WriteBelow ("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);","[[IPAYiAppPay sharediAppPay] handleOpenurl:url];\n"); // UnityAppController.WriteBelow ("UnitySendRemoteNotificationError(error);\n}","-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\n{\n[[IPAYiAppPay sharediAppPay] handleOpenurl:url];\nreturn YES;\n}"); //SDK_I4 // UnityAppController.WriteBelow ("#include \"PluginBase/AppDelegateListener.h\"","#import \"AsInfoKit.h\""); // UnityAppController.WriteBelow ("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);","if ([sourceApplication isEqualToString:@\"com.alipay.iphoneclient\"])\n{\n [[AsInfoKit sharedInstance] alixPayResult:url];\n}\nelse if ([sourceApplication isEqualToString:@\"com.alipay.safepayclient\"])\n{\n[[AsInfoKit sharedInstance] alixPayResult:url];\n}\nelse if ([sourceApplication isEqualToString:@\"com.tencent.xin\"])\n{\n[[AsInfoKit sharedInstance] weChatPayResult:url];\n}\n"); //SDK_itools // have no EditorCode //SDK_KUAIYONG // UnityAppController.WriteBelow ("#include \"PluginBase/AppDelegateListener.h\"","#import <AlipaySDK/AlipaySDK.h>"); // UnityAppController.WriteBelow ("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);"," if ([url.host isEqualToString:@\"safepay\"]) {\n[[AlipaySDK defaultService] processOderWithPaymentResult:url];\n}"); //SDK_PP // UnityAppController.WriteBelow ("#include \"PluginBase/AppDelegateListener.h\"","#import <PPAppPlatformKit/PPAppPlatformKit.h>"); // UnityAppController.WriteBelow ("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);","[[PPAppPlatformKit sharedInstance] alixPayResult:url];\n"); //在指定代码中替换一行 // UnityAppController.Replace("return YES;","return [ShareSDK handleOpenURL:url sourceApplication:sourceApplication annotation:annotation wxDelegate:nil];"); XClass UnityViewControllerBase = new XClass(filePath + "/Classes/UI/UnityViewControllerBase.h"); UnityViewControllerBase.WriteBelow("#import <UIKit/UIKit.h>", "#import \"MBProgressHUD.h\""); UnityViewControllerBase.WriteBelow("- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;", "-(void)showSimple;"); XClass UnityViewControllerBasem = new XClass(filePath + "/Classes/UI/UnityViewControllerBase.mm"); UnityViewControllerBasem.WriteBelow("AddStatusBarSupportDefaultImpl(targetClass);\n}", "@interface UnityViewControllerBase () <MBProgressHUDDelegate> {\r MBProgressHUD *HUD;\r long long expectedLength;\r long long currentLength;\r}\r@end"); UnityViewControllerBasem.WriteBelow("[UIView setAnimationsEnabled:YES];\n}", "-(void)showSimple \r{\r HUD = [[MBProgressHUD alloc] initWithView:UnityGetGLView()];\r [UnityGetGLView() addSubview:HUD];\r [UnityGetGLView() bringSubviewToFront:HUD];\r // Regiser for HUD callbacks so we can remove it from the window at the right time \r HUD.delegate = self;\r // Show the HUD while the provided method executes in a new thread \r [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];\r}\r - (void)myTask {\r // Do something usefull in here instead of sleeping ... \r sleep(1);\r}"); }
private static void PrepareIdentifiers() { namespaces.Clear(); XNamespace currentNamespace = null; XClass currentClass = null; XRef currentFile = null; XMethod currentMethod = null; String path = null; int ante, from, blockAt, to; foreach (string line in File.ReadAllLines(file)) { ante = 0; from = 0; blockAt = 0; to = 0; string[] elements = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (elements.Length > 0) { switch (elements[0]) { case "N": currentNamespace = new XNamespace(elements[1]); namespaces.Add(currentNamespace); break; case "\tC": currentClass = new XClass(elements[1]); currentNamespace.Classes.Add(currentClass); break; case "\t\tF": currentFile = new XRef(new FileInfo(elements[1]), 0, 0, 0); currentClass.Files.Add(currentFile); break; case "\t\t\tM": currentMethod = new XMethod(elements[1]); currentFile.Methods.Add(currentMethod); string[] markers = elements[elements.Length - 1].Split(':'); if (markers.Length == 4) { int.TryParse(markers[0], out ante); Array.Copy(markers, 1, markers, 0, markers.Length - 1); } if (int.TryParse(markers[0], out from) && int.TryParse(markers[1], out blockAt) && int.TryParse(markers[2], out to)) { currentMethod.File = new XRef(currentFile.File, from, blockAt, to); } break; default: break; } } } }
private static void EditorCodeYaya(string filePath) { // UnityAppController.mm XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import <GameUser_framwork/YvGameUserAPIManage.h>\n#define SDK_APPID @\"1438496089\""); UnityAppController.WriteBelow("[KeyboardDelegate Initialize];", "[[YvGameUserAPIManage shareInstance] initWithAppId:SDK_APPID channelId:@\"xxsg001\" urlScheme:@\"com.xxsg.zhangm1438496089\" isTest:NO];"); }
private static void EditorCodeLvke(string filePath) { // UnityAppController.mm XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import <GameFramework/GameFramework.h>"); UnityAppController.WriteBelow("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);", "[Game_Api Game_application:application openURL:url sourceApplication:sourceApplication annotation:annotation];"); }
private static void EditorCode(string filePath) { //读取UnityAppController.mm文件 XClass UnityAppController = new XClass(filePath + "/Classes/Unity/CMVideoSampling.mm"); //在指定代码中替换一行 UnityAppController.Replace("#include <OpenGLES/ES2/gl.h>", "#include <OpenGLES/ES2/glext.h>"); }
private void EditCode(string filePath) { XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); for (int i = 0; i < codeEditList.Count; ++i) { codeEditList[i].EditCode(UnityAppController); } }
private static void EditorCode(string filePath) { XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.h"); UnityAppController.Replace("NSObject<UIApplicationDelegate>", "TestAppDelegate"); UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); UnityAppController.Replace("[KeyboardDelegate Initialize];\n\n\treturn YES;", "[KeyboardDelegate Initialize];\n\n\treturn [super application:application didFinishLaunchingWithOptions:launchOptions];"); }
private static void EditorCodeZaya(string filePath) { // UnityAppController.mm XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import <ZAYAGame/ZaYaGameHeader.h>"); UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import <ZayaSdkConector.h>"); UnityAppController.WriteBelow("[GetAppController().unityView recreateGLESSurfaceIfNeeded];", "[[ZaYaGame sharedInstance] setSDKEnterForeground];"); UnityAppController.WriteBelow("[KeyboardDelegate Initialize];", "[[ZaYaGame sharedInstance]\n setAppID:9002\n AppKey:@\"18b33bcedf1b2c907611c7305e8dcdb3\"\n UmengKey:@\"579c09afe0f55a498a002028\"\n TalkingDataAdTracking:@\"76047EF6A58B87AE5CF4C86E61FCDF19\"\n GameOrientation:GAMEInterfaceOrientationPortrait\n LaunchOptions:launchOptions];"); }
private static void EditorCodeFixIOSInput(string filePath) { //读取Keyboard.mm文件 XClass UnityAppController = new XClass(filePath + "/Classes/UI/Keyboard.mm"); UnityAppController.Replace("#include \"Keyboard.h\"\n#include \"DisplayManager.h\"\n#include \"UnityForwardDecls.h\"\n#include <string>\n\n// Respect values passed from prefix header or CFlags\n#ifndef FILTER_EMOJIS_IOS_KEYBOARD \n// Set this flag to 0 in order to allow emoji symbols to be entered in the iOS keyboard.\n#define FILTER_EMOJIS_IOS_KEYBOARD 1\n#endif\n\nstatic KeyboardDelegate*\t_keyboard = nil;\n\nstatic bool\t\t\t\t\t_shouldHideInput = false;\nstatic bool\t\t\t\t\t_shouldHideInputChanged = false;\nstatic const unsigned\t\tkToolBarHeight = 64;\n\nenum KeyboardVisibleState {\n\tkPrepareToShow, // Keyboard has been scheduled to become visible.\n\tkDidShow, // Keyboard is visible.\n\tkPrepareToHide, // Keyboard has been scheduled to hide.\n\tkDidHide // Keyboard is hidden.\n};\n\n@interface KeyboardDelegate ()\n// This state is used to determine when the keyboard is active or not. The keyboard becomes active\n// as soon as it is scheduled to become visible (but before it's actually visible). We do this\n// because there was a bug where tapping on an InputField can cause back-to-back calls to\n// OnSelect() then OnDeselect() to happen.\n// What used to happen (the bug): If you tap on InputField A and enter some text, then tap on\n// InputField B in the same scene, you will see that InputField A receives the correct sequence\n// of OnDeselect(), TextDidEndEditing, etc. Then, you'll see InputField B get the correct\n// OnSelect() call, but then it gets an OnDeselect() call. This happened because the InputField\n// C# code looks at the active bit in the keyboard during a LateUpdate() cycle. At the time the\n// active bit is checked, the keyboard is in the middle of its hide / show cycle, and is temporarily\n// inactive.\n// The fix: using this state ivar decouples the existence of the keyboard view (and it's editView)\n// from whether the keyboard is active or not.\n@property (nonatomic) KeyboardVisibleState visibleState;\n@end\n\n@implementation KeyboardDelegate\n{\n\t// UI handling\n\t// in case of single line we use UITextField inside UIToolbar\n\t// in case of multi-line input we use UITextView with UIToolbar as accessory view\n\t// toolbar buttons are kept around to prevent releasing them\n\t// tvOS does not support multiline input thus only UITextField option is implemented\n#if UNITY_IOS\n\tUITextView*\t\ttextView;\n\n\tUIToolbar*\t\tviewToolbar;\n\tNSArray*\t\tviewToolbarItems;\n#endif\n\n\tUITextField*\ttextField;\n\n\t// keep toolbar items for both single- and multi- line edit in NSArray to make sure they are kept around\n#if UNITY_IOS\n\tUIToolbar*\t\tfieldToolbar;\n\tNSArray*\t\tfieldToolbarItems;\n#endif\n\n\t// inputView is view used for actual input (it will be responder): UITextField [single-line] or UITextView [multi-line]\n\t// editView is the \"root\" view for keyboard: UIToolbar [single-line] or UITextView [multi-line]\n\tUIView*\t\t\tinputView;\n\tUIView*\t\t\teditView;\n\n\n\tCGRect\t\t\t_area;\n\tNSString*\t\tinitialText;\n\n\tUIKeyboardType\tkeyboardType;\n\n\tBOOL\t\t\t_multiline;\n\tBOOL\t\t\t_inputHidden;\n\tBOOL\t\t\t_done;\n\tBOOL\t\t\t_canceled;\n\n\tBOOL\t\t\t_rotating;\n}\n\n@synthesize area;\n@synthesize done\t\t= _done;\n@synthesize canceled\t= _canceled;\n@synthesize text;\n\n// While emoji symbols are still shown in the iOS keyboard, they are all filtered by the\n// shouldChangeCharactersInRange method below.\n#if FILTER_EMOJIS_IOS_KEYBOARD\n\nbool stringContainsEmoji(NSString *string)\n{\n\t__block BOOL returnValue = NO;\n\t[string enumerateSubstringsInRange:NSMakeRange(0, [string length])\n\t\toptions:NSStringEnumerationByComposedCharacterSequences\n\t\tusingBlock: ^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop)\n\t\t{\n\t\t\tconst unichar hs = [substring characterAtIndex:0];\n\t\t\n\t\t\t// Surrogate pair\n\t\t\tif(hs >= 0xD800 && hs <= 0xDBFF)\n\t\t\t{\n\t\t\t\tif(substring.length > 1)\n\t\t\t\t{\n\t\t\t\t\t// Compute the code point in the U+10000 - U+10FFFF plane.\n\t\t\t\t\tconst unichar ls = [substring characterAtIndex:1];\n\t\t\t\t\tconst int uc = ((hs - 0xD800) * 0x400) + (ls - 0xDC00) + 0x10000;\n\t\t\t\t\n\t\t\t\t\t// The ranges for the various emoji tables are as follows.\n\t\t\t\t\t// Musical -> [U+1D000, U+1D24F]\n\t\t\t\t\t// Miscellaneous Symbols and Pictographs -> [U+1F300, U+1F5FF]\n\t\t\t\t\t// Emoticons -> [U+1F600, U+1F64F]\n\t\t\t\t\t// Transport and Map Symbols -> [U+1F680, U+1F6FF]\n\t\t\t\t\t// Supplemental Symbols and Pictographs -> [U+1F900, U+1F9FF]\n\t\t\t\t\tif(uc >= 0x1D000 && uc <= 0x1F9FF)\n\t\t\t\t\t{\n\t\t\t\t\t\treturnValue = YES;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(substring.length > 1)\n\t\t\t{\n\t\t\t\tconst unichar ls = [substring characterAtIndex:1];\n\t\t\t\n\t\t\t\tif(ls == 0x20E3)\n\t\t\t\t{\n\t\t\t\t\t// Filter all the emojis for numbers.\n\t\t\t\t\treturnValue = YES;\n\t\t\t\t}\n\t\t\t\telse if(hs >= 0x270A && hs <= 0x270D)\n\t\t\t\t{\n\t\t\t\t\t// Filter all the various hand symbols (e.g., victory sign, writing hand, etc).\n\t\t\t\t\treturnValue = YES;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// Non surrogate pair.\n\t\t\t\tif(hs >= 0x2100 && hs <= 0x27FF)\n\t\t\t\t{\n\t\t\t\t\t// Filter the following emoji ranges.\n\t\t\t\t\t// Letterlike Symbols -> [U+2100, U+214F]\n\t\t\t\t\t// Number Forms -> [U+2150, U+218F]\n\t\t\t\t\t// Arrows -> [U+2190, U+21FF]\n\t\t\t\t\t// Dingbats -> [U+2700, U+27BF]\n\t\t\t\t\t// Supplemental Arrows-A -> [U+27F0–U+27FF]\n\t\t\t\t\treturnValue = YES;\n\t\t\t\t}\n\t\t\t\telse if(hs >= 0x2900 && hs <= 0x297F)\n\t\t\t\t{\n\t\t\t\t\t// Filter Supplemental Arrows-B -> [U+2900, U+297F]\n\t\t\t\t\treturnValue = YES;\n\t\t\t\t}\n\t\t\t\telse if(hs >= 0x2B05 && hs <= 0x2BFF)\n\t\t\t\t{\n\t\t\t\t\t// Filter Miscellaneous Symbols and Arrows -> [U+2B00, U+2BFF]\n\t\t\t\t\treturnValue = YES;\n\t\t\t\t}\n\t\t\t}\n\t\t}];\n\t\n\treturn returnValue;\n}\n\n// See the documentation for this method in http://apple.co/1OMnz8D.\n-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string\n{\n\t// Process the input string using the 'stringContainsEmoji' function and return NO or YES\n\t// depending on whether it needs to be added to the UITexField or skipped altogether, respectively.\n\t// We need to do this because Unity's UI doesn't provide proper Unicode support yet.\n\treturn !stringContainsEmoji(string);\n}\n\n#endif // FILTER_EMOJIS_IOS_KEYBOARD\n\n- (BOOL)textFieldShouldReturn:(UITextField*)textFieldObj\n{\n\t[self hide];\n\treturn YES;\n}\n- (void)textInputDone:(id)sender\n{\n\t[self hide];\n}\n- (void)textInputCancel:(id)sender\n{\n\t_canceled = true;\n\t[self hide];\n}\n\n- (BOOL)textViewShouldBeginEditing:(UITextView*)view\n{\n#if !UNITY_TVOS\n\tview.inputAccessoryView = viewToolbar;\n#endif\n\treturn YES;\n}\n\n#if UNITY_IOS\n- (void)keyboardDidShow:(NSNotification*)notification\n{\n\tif (notification.userInfo == nil || inputView == nil)\n\t\treturn;\n\n\tCGRect srcRect\t= [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];\n\tCGRect rect\t\t= [UnityGetGLView() convertRect:srcRect fromView:nil];\n\n\t[self positionInput:rect x:rect.origin.x y:rect.origin.y];\n\tself.visibleState = kDidShow;\n}\n\n- (void)keyboardWillHide:(NSNotification*)notification\n{\n\t[self systemHideKeyboard];\n}\n\n- (void)keyboardDidHide:(NSNotification *)notification\n{\n\t// If the keyboard is currently scheduled to be shown, then don't change its\n\t// visible state here. This can happen when you change focus directly from one\n\t// input field to another one in the same scene. When you change focus in this way,\n\t// the C# code hides the keyboard when the first InputField loses focus (OnDeselect() is\n\t// called), and then it schedules the keyboard to be shown to be shown when the second\n\t// InputField receives focus (OnSelect() is called). However, the notification that the\n\t// keyboard was hidden is received here *after* the C# code has scheduled the keyboard to\n\t// be shown. See the comment above the visibleState ivar for more information.\n\tif (self.visibleState != kPrepareToShow) {\n\t\tself.visibleState = kDidHide;\n\t}\n}\n\n- (void)keyboardDidChangeFrame:(NSNotification*)notification\n{\n\tCGRect srcRect\t= [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];\n\tCGRect rect\t\t= [UnityGetGLView() convertRect:srcRect fromView: nil];\n\n\tif(rect.origin.y >= [UnityGetGLView() bounds].size.height)\n\t\t[self systemHideKeyboard];\n\telse\n\t\t[self positionInput:rect x:rect.origin.x y:rect.origin.y];\n}\n#endif\n\n+ (void)Initialize\n{\n\tNSAssert(_keyboard == nil, @\"[KeyboardDelegate Initialize] called after creating keyboard\");\n\tif(!_keyboard)\n\t\t_keyboard = [[KeyboardDelegate alloc] init];\n}\n\n+ (KeyboardDelegate*)Instance\n{\n\tif(!_keyboard)\n\t\t_keyboard = [[KeyboardDelegate alloc] init];\n\treturn _keyboard;\n}\n\n#if UNITY_IOS\nstruct CreateToolbarResult\n{\n\tUIToolbar*\ttoolbar;\n\tNSArray*\titems;\n};\n- (CreateToolbarResult)createToolbarWithView:(UIView*)view\n{\n\tUIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,160,320, kToolBarHeight)];\n\tUnitySetViewTouchProcessing(toolbar, touchesIgnored);\n\ttoolbar.hidden = NO;\n\n\tUIBarButtonItem* inputItem\t= view ? [[UIBarButtonItem alloc] initWithCustomView:view] : nil;\n\tUIBarButtonItem* doneItem\t= [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(textInputDone:)];\n\tUIBarButtonItem* cancelItem\t= [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(textInputCancel:)];\n\n\tNSArray* items = view ? @[inputItem, doneItem, cancelItem] : @[doneItem, cancelItem];\n\ttoolbar.items = items;\n\n\tinputItem = nil;\n\tdoneItem = nil;\n\tcancelItem = nil;\n\n\tCreateToolbarResult ret = {toolbar, items};\n\treturn ret;\n}\n#endif\n\n- (id)init\n{\n\tNSAssert(_keyboard == nil, @\"You can have only one instance of KeyboardDelegate\");\n\tself = [super init];\n\tif(self)\n\t{\n#if UNITY_IOS\n\t\ttextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 480, 480, 30)];\n\t\ttextView.delegate = self;\n\t\ttextView.font = [UIFont systemFontOfSize:18.0];\n\t\ttextView.hidden = YES;\n#endif\n\n\t\ttextField = [[UITextField alloc] initWithFrame:CGRectMake(0,0,120,30)];\n\t\ttextField.delegate = self;\n\t\ttextField.borderStyle = UITextBorderStyleRoundedRect;\n\t\ttextField.font = [UIFont systemFontOfSize:20.0];\n\t\ttextField.clearButtonMode = UITextFieldViewModeWhileEditing;\n\n\t\t#define CREATE_TOOLBAR(t, i, v)\t\t\t\t\t\t\t\t\t\\\n\t\tdo {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n\t\t\tCreateToolbarResult res = [self createToolbarWithView:v];\t\\\n\t\t\tt = res.toolbar;\t\t\t\t\t\t\t\t\t\t\t\\\n\t\t\ti = res.items;\t\t\t\t\t\t\t\t\t\t\t\t\\\n\t\t} while(0)\n\n#if UNITY_IOS\n\t\tCREATE_TOOLBAR(viewToolbar, viewToolbarItems, nil);\n\t\tCREATE_TOOLBAR(fieldToolbar, fieldToolbarItems, textField);\n#endif\n\n\t\t#undef CREATE_TOOLBAR\n\n#if UNITY_IOS\n\t\t[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];\n\t\t[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];\n\t\t[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];\n\t\t[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidChangeFrame:) name:UIKeyboardDidChangeFrameNotification object:nil];\n#endif\n\t\t\n\t\t[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textInputDone:) name:UITextFieldTextDidEndEditingNotification object:nil];\n\t}\n\n\treturn self;\n}\n\n- (BOOL)active {\n\t// The keyboard is active when it is in an active state (either it is about to be shown, or it\n\t// is currently shown), OR when the edit view is hte first responder. Checking the first\n\t// responder bit is necessary because the suggestion list for some multi-byte languages can take over\n\t// the entire screen, which renders the keyboard temporarily invisble.\n\treturn self.visibleState == kPrepareToShow || self.visibleState == kDidShow || editView.isFirstResponder;\n}\n\n- (void) setTextInputTraits: (id<UITextInputTraits>) traits\n\t\t\t\t withParam: (KeyboardShowParam) param\n\t\t\t\t\twithCap: (UITextAutocapitalizationType) capitalization\n{\n\ttraits.keyboardType\t= param.keyboardType;\n\ttraits.autocorrectionType = param.autocorrectionType;\n\ttraits.secureTextEntry = param.secure;\n\ttraits.keyboardAppearance = param.appearance;\n\ttraits.autocapitalizationType = capitalization;\n}\n\n- (void)setKeyboardParams:(KeyboardShowParam)param\n{\n\tif(self.active)\n\t\t[self hide];\n\n\tinitialText = param.text ? [[NSString alloc] initWithUTF8String: param.text] : @\"\";\n\n\tUITextAutocapitalizationType capitalization = UITextAutocapitalizationTypeSentences;\n\tif(param.keyboardType == UIKeyboardTypeURL || param.keyboardType == UIKeyboardTypeEmailAddress)\n\t\tcapitalization = UITextAutocapitalizationTypeNone;\n\n#if UNITY_IOS\n\t_multiline = param.multiline;\n\tif (_multiline)\n\t{\n\t\ttextView.text = initialText;\n\t\t[self setTextInputTraits:textView withParam:param withCap:capitalization];\n\t}\n\telse\n\t{\n\t\ttextField.text = initialText;\n\t\t[self setTextInputTraits:textField withParam:param withCap:capitalization];\n\t\ttextField.placeholder = [NSString stringWithUTF8String:param.placeholder];\n\t}\n\tinputView = _multiline ? textView : textField;\n\teditView = _multiline ? textView : fieldToolbar;\n\n#else // UNITY_TVOS\n\ttextField.text = initialText;\n\t[self setTextInputTraits:textField withParam:param withCap:capitalization];\n\ttextField.placeholder = [NSString stringWithUTF8String:param.placeholder];\n\tinputView = textField;\n\teditView = textField;\n#endif\n\n\t[self shouldHideInput:_shouldHideInput];\n\n\t_done\t\t= NO;\n\t_canceled\t= NO;\n}\n\n// we need to show/hide keyboard to react to orientation too, so extract we extract UI fiddling\n\n- (void)showUI\n{\n\t// if we unhide everything now the input will be shown smaller then needed quickly (and resized later)\n\t// so unhide only when keyboard is actually shown (we will update it when reacting to ios notifications)\n\teditView.hidden = YES;\n\n\t[UnityGetGLView() addSubview:editView];\n\t[inputView becomeFirstResponder];\n}\n- (void)hideUI\n{\n\tself.visibleState = kPrepareToHide;\n\t[inputView resignFirstResponder];\n\n\t[editView removeFromSuperview];\n\teditView.hidden = YES;\n}\n- (void)systemHideKeyboard\n{\n\t// It's possible that the keyboard goes through a hide / show cycle even though it\n\t// should remain active. For example, when changing focus between InputFields by\n\t// tapping (see comment above regarding the visibleState ivar). For this reason,\n\t// do not change visibleState in this method.\n\n\teditView.hidden = YES;\n\n\t_area = CGRectMake(0,0,0,0);\n}\n\n- (void)show\n{\n\t[self showUI];\n}\n- (void)hide\n{\n\t[self hideUI];\n\t_done = YES;\n}\n\n- (void)updateInputHidden\n{\n\tif(_shouldHideInputChanged)\n\t{\n\t\t[self shouldHideInput:_shouldHideInput];\n\t\t_shouldHideInputChanged = false;\n\t}\n\n\ttextField.returnKeyType = _inputHidden ? UIReturnKeyDone : UIReturnKeyDefault;\n\n\teditView.hidden\t\t= _inputHidden ? YES : NO;\n\tinputView.hidden\t= _inputHidden ? YES : NO;\n}\n\n#if UNITY_IOS\n- (void)positionInput:(CGRect)kbRect x:(float)x y:(float)y\n{\n\tif(_multiline)\n\t{\n\t\t// use smaller area for iphones and bigger one for ipads\n\t\tint height = UnityDeviceDPI() > 300 ? 75 : 100;\n\n\t\teditView.frame\t= CGRectMake(0, y - kToolBarHeight, kbRect.size.width, height);\n\t}\n\telse\n\t{\n\t\tCGRect statusFrame\t= [UIApplication sharedApplication].statusBarFrame;\n\t\tunsigned statusHeight\t= statusFrame.size.height;\n\n\t\teditView.frame\t= CGRectMake(0, y - kToolBarHeight - statusHeight, kbRect.size.width, kToolBarHeight);\n inputView.frame\t= CGRectMake(inputView.frame.origin.x,\n inputView.frame.origin.y,\n kbRect.size.width - 3*18 - 2*50,\n inputView.frame.size.height);\n\t}\n\n\t_area = CGRectMake(x, y, kbRect.size.width, kbRect.size.height);\n\t[self updateInputHidden];\n}\n#endif\n\n- (CGRect)queryArea\n{\n\treturn editView.hidden ? _area : CGRectUnion(_area, editView.frame);\n}\n\n+ (void)StartReorientation\n{\n\tif(_keyboard && _keyboard.active)\n\t{\n\t\t[CATransaction begin];\n\t\t[_keyboard hideUI];\n\t\t[CATransaction commit];\n\n\t\t// not pretty but seems like easiest way to keep \"we are rotating\" status\n\t\t_keyboard->_rotating = YES;\n\t}\n}\n\n+ (void)FinishReorientation\n{\n\tif(_keyboard && _keyboard->_rotating)\n\t{\n\t\t[CATransaction begin];\n\t\t[_keyboard showUI];\n\t\t[CATransaction commit];\n\n\t\t_keyboard->_rotating = NO;\n\t}\n}\n\n- (NSString*)getText\n{\n\tif (_canceled)\n\t\treturn initialText;\n\telse\n\t{\n#if UNITY_TVOS\n\t\treturn [textField text];\n#else\n\t\treturn _multiline ? [textView text] : [textField text];\n#endif\n\t}\n}\n\n- (void) setTextWorkaround:(id<UITextInput>)textInput text:(NSString*)newText\n{\n\tUITextPosition* begin = [textInput beginningOfDocument];\n\tUITextPosition* end = [textInput endOfDocument];\n\tUITextRange* allText = [textInput textRangeFromPosition:begin toPosition:end];\n\t[textInput setSelectedTextRange:allText];\n\t[textInput insertText:newText];\n}\n\n- (void)setText:(NSString*)newText\n{\n#if UNITY_IOS\n\t// We can't use setText on iOS7 because it does not update the undo stack.\n\t// We still prefer setText on other iOSes, because an undo operation results\n\t// in a smaller selection shown on the UI\n\tif(_ios70orNewer && !_ios80orNewer)\n\t\t[self setTextWorkaround: (_multiline ? textView : textField) text:newText];\n\n\tif(_multiline)\n\t\ttextView.text = newText;\n\telse\n\t\ttextField.text = newText;\n#else\n\ttextField.text = newText;\n#endif\n}\n\n- (void)shouldHideInput:(BOOL)hide\n{\n\tif(hide)\n\t{\n\t\tswitch(keyboardType)\n\t\t{\n\t\t\tcase UIKeyboardTypeDefault: hide = YES;\tbreak;\n\t\t\tcase UIKeyboardTypeASCIICapable: hide = YES;\tbreak;\n\t\t\tcase UIKeyboardTypeNumbersAndPunctuation: hide = YES;\tbreak;\n\t\t\tcase UIKeyboardTypeURL: hide = YES;\tbreak;\n\t\t\tcase UIKeyboardTypeNumberPad: hide = NO;\tbreak;\n\t\t\tcase UIKeyboardTypePhonePad: hide = NO;\tbreak;\n\t\t\tcase UIKeyboardTypeNamePhonePad: hide = NO;\tbreak;\n\t\t\tcase UIKeyboardTypeEmailAddress: hide = YES;\tbreak;\n\t\t\tdefault: hide = NO;\tbreak;\n\t\t}\n\t}\n\n\t_inputHidden = hide;\n}\n\n@end\n\n\n\n//==============================================================================\n//\n// Unity Interface:\n\nextern \"C\" void UnityKeyboard_Create(unsigned keyboardType, int autocorrection, int multiline, int secure, int alert, const char* text, const char* placeholder)\n{\n#if UNITY_TVOS\n\t// Not supported. The API for showing keyboard for editing multi-line text\n\t// is not available on tvOS\n\tmultiline = false;\n#endif\n\t\n\tstatic const UIKeyboardType keyboardTypes[] =\n\t{\n\t\tUIKeyboardTypeDefault,\n\t\tUIKeyboardTypeASCIICapable,\n\t\tUIKeyboardTypeNumbersAndPunctuation,\n\t\tUIKeyboardTypeURL,\n\t\tUIKeyboardTypeNumberPad,\n\t\tUIKeyboardTypePhonePad,\n\t\tUIKeyboardTypeNamePhonePad,\n\t\tUIKeyboardTypeEmailAddress,\n\t};\n\n\tstatic const UITextAutocorrectionType autocorrectionTypes[] =\n\t{\n\t\tUITextAutocorrectionTypeNo,\n\t\tUITextAutocorrectionTypeDefault,\n\t};\n\n\tstatic const UIKeyboardAppearance keyboardAppearances[] =\n\t{\n\t\tUIKeyboardAppearanceDefault,\n\t\tUIKeyboardAppearanceAlert,\n\t};\n\n\tKeyboardShowParam param =\n\t{\n\t\ttext, placeholder,\n\t\tkeyboardTypes[keyboardType],\n\t\tautocorrectionTypes[autocorrection],\n\t\tkeyboardAppearances[alert],\n\t\t(BOOL)multiline, (BOOL)secure\n\t};\n\n\t[[KeyboardDelegate Instance] setKeyboardParams:param];\n}\n\nextern \"C\" void UnityKeyboard_PrepareToShow()\n{\n\t[KeyboardDelegate Instance].visibleState = kPrepareToShow;\n}\n\nextern \"C\" void UnityKeyboard_Show()\n{\n\t// do not send hide if didnt create keyboard\n\t// TODO: probably assert?\n\tif(!_keyboard)\n\t\treturn;\n\n\t[[KeyboardDelegate Instance] show];\n}\n\nextern \"C\" void UnityKeyboard_Hide()\n{\n\t// do not send hide if didnt create keyboard\n\t// TODO: probably assert?\n\tif(!_keyboard)\n\t\treturn;\n\n\t[[KeyboardDelegate Instance] hide];\n}\n\nextern \"C\" void UnityKeyboard_SetText(const char* text)\n{\n\t[KeyboardDelegate Instance].text = [NSString stringWithUTF8String: text];\n}\n\nextern \"C\" NSString* UnityKeyboard_GetText()\n{\n\treturn [KeyboardDelegate Instance].text;\n}\n\nextern \"C\" int UnityKeyboard_IsActive()\n{\n\treturn (_keyboard && _keyboard.active) ? 1 : 0;\n}\n\nextern \"C\" int UnityKeyboard_IsDone()\n{\n\treturn (_keyboard && _keyboard.done) ? 1 : 0;\n}\n\nextern \"C\" int UnityKeyboard_WasCanceled()\n{\n\treturn (_keyboard && _keyboard.canceled) ? 1 : 0;\n}\n\nextern \"C\" void UnityKeyboard_SetInputHidden(int hidden)\n{\n\t_shouldHideInput\t\t= hidden;\n\t_shouldHideInputChanged\t= true;\n\n\t// update hidden status only if keyboard is on screen to avoid showing input view out of nowhere\n\tif(_keyboard && _keyboard.active)\n\t\t[_keyboard updateInputHidden];\n}\n\nextern \"C\" int UnityKeyboard_IsInputHidden()\n{\n\treturn _shouldHideInput ? 1 : 0;\n}\n\nextern \"C\" void UnityKeyboard_GetRect(float* x, float* y, float* w, float* h)\n{\n\tCGRect area = _keyboard ? _keyboard.area : CGRectMake(0,0,0,0);\n\n\t// convert to unity coord system\n\n\tfloat\tmultX\t= (float)GetMainDisplaySurface()->targetW / UnityGetGLView().bounds.size.width;\n\tfloat\tmultY\t= (float)GetMainDisplaySurface()->targetH / UnityGetGLView().bounds.size.height;\n\n\t*x = 0;\n\t*y = area.origin.y * multY;\n\t*w = area.size.width * multX;\n\t*h = area.size.height * multY;\n}\n" , "#include \"Keyboard.h\"\n#include \"DisplayManager.h\"\n#include \"UnityForwardDecls.h\"\n#include <string>\n\n// Respect values passed from prefix header or CFlags\n#ifndef FILTER_EMOJIS_IOS_KEYBOARD \n// Set this flag to 0 in order to allow emoji symbols to be entered in the iOS keyboard.\n#define FILTER_EMOJIS_IOS_KEYBOARD 1\n#endif\n\nstatic KeyboardDelegate*\t_keyboard = nil;\n\nstatic bool\t\t\t\t\t_shouldHideInput = false;\nstatic bool\t\t\t\t\t_shouldHideInputChanged = false;\nstatic const unsigned\t\tkToolBarHeight = 64;\n\nenum KeyboardVisibleState {\n\tkPrepareToShow, // Keyboard has been scheduled to become visible.\n\tkDidShow, // Keyboard is visible.\n\tkPrepareToHide, // Keyboard has been scheduled to hide.\n\tkDidHide // Keyboard is hidden.\n};\n\n@interface KeyboardDelegate ()\n// This state is used to determine when the keyboard is active or not. The keyboard becomes active\n// as soon as it is scheduled to become visible (but before it's actually visible). We do this\n// because there was a bug where tapping on an InputField can cause back-to-back calls to\n// OnSelect() then OnDeselect() to happen.\n// What used to happen (the bug): If you tap on InputField A and enter some text, then tap on\n// InputField B in the same scene, you will see that InputField A receives the correct sequence\n// of OnDeselect(), TextDidEndEditing, etc. Then, you'll see InputField B get the correct\n// OnSelect() call, but then it gets an OnDeselect() call. This happened because the InputField\n// C# code looks at the active bit in the keyboard during a LateUpdate() cycle. At the time the\n// active bit is checked, the keyboard is in the middle of its hide / show cycle, and is temporarily\n// inactive.\n// The fix: using this state ivar decouples the existence of the keyboard view (and it's editView)\n// from whether the keyboard is active or not.\n@property (nonatomic) KeyboardVisibleState visibleState;\n@end\n\n@implementation KeyboardDelegate\n{\n\t// UI handling\n\t// in case of single line we use UITextField inside UIToolbar\n\t// in case of multi-line input we use UITextView with UIToolbar as accessory view\n\t// toolbar buttons are kept around to prevent releasing them\n\t// tvOS does not support multiline input thus only UITextField option is implemented\n#if UNITY_IOS\n\tUITextView*\t\ttextView;\n\n\tUIToolbar*\t\tviewToolbar;\n\tNSArray*\t\tviewToolbarItems;\n#endif\n\n\tUITextField*\ttextField;\n\n\t// keep toolbar items for both single- and multi- line edit in NSArray to make sure they are kept around\n#if UNITY_IOS\n\tUIToolbar*\t\tfieldToolbar;\n\tNSArray*\t\tfieldToolbarItems;\n#endif\n\n\t// inputView is view used for actual input (it will be responder): UITextField [single-line] or UITextView [multi-line]\n\t// editView is the \"root\" view for keyboard: UIToolbar [single-line] or UITextView [multi-line]\n\tUIView*\t\t\tinputView;\n\tUIView*\t\t\teditView;\n\n\n\tCGRect\t\t\t_area;\n\tNSString*\t\tinitialText;\n\n\tUIKeyboardType\tkeyboardType;\n\n\tBOOL\t\t\t_multiline;\n\tBOOL\t\t\t_inputHidden;\n\tBOOL\t\t\t_active;\n\tBOOL\t\t\t_done;\n\tBOOL\t\t\t_canceled;\n\n\tBOOL\t\t\t_rotating;\n}\n\n@synthesize area;\n@synthesize active\t\t= _active;\n@synthesize done\t\t= _done;\n@synthesize canceled\t= _canceled;\n@synthesize text;\n\n// While emoji symbols are still shown in the iOS keyboard, they are all filtered by the\n// shouldChangeCharactersInRange method below.\n#if FILTER_EMOJIS_IOS_KEYBOARD\n\nbool stringContainsEmoji(NSString *string)\n{\n\t__block BOOL returnValue = NO;\n\t[string enumerateSubstringsInRange:NSMakeRange(0, [string length])\n\t\toptions:NSStringEnumerationByComposedCharacterSequences\n\t\tusingBlock: ^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop)\n\t\t{\n\t\t\tconst unichar hs = [substring characterAtIndex:0];\n\t\t\n\t\t\t// Surrogate pair\n\t\t\tif(hs >= 0xD800 && hs <= 0xDBFF)\n\t\t\t{\n\t\t\t\tif(substring.length > 1)\n\t\t\t\t{\n\t\t\t\t\t// Compute the code point in the U+10000 - U+10FFFF plane.\n\t\t\t\t\tconst unichar ls = [substring characterAtIndex:1];\n\t\t\t\t\tconst int uc = ((hs - 0xD800) * 0x400) + (ls - 0xDC00) + 0x10000;\n\t\t\t\t\n\t\t\t\t\t// The ranges for the various emoji tables are as follows.\n\t\t\t\t\t// Musical -> [U+1D000, U+1D24F]\n\t\t\t\t\t// Miscellaneous Symbols and Pictographs -> [U+1F300, U+1F5FF]\n\t\t\t\t\t// Emoticons -> [U+1F600, U+1F64F]\n\t\t\t\t\t// Transport and Map Symbols -> [U+1F680, U+1F6FF]\n\t\t\t\t\t// Supplemental Symbols and Pictographs -> [U+1F900, U+1F9FF]\n\t\t\t\t\tif(uc >= 0x1D000 && uc <= 0x1F9FF)\n\t\t\t\t\t{\n\t\t\t\t\t\treturnValue = YES;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(substring.length > 1)\n\t\t\t{\n\t\t\t\tconst unichar ls = [substring characterAtIndex:1];\n\t\t\t\n\t\t\t\tif(ls == 0x20E3)\n\t\t\t\t{\n\t\t\t\t\t// Filter all the emojis for numbers.\n\t\t\t\t\treturnValue = YES;\n\t\t\t\t}\n\t\t\t\telse if(hs >= 0x270A && hs <= 0x270D)\n\t\t\t\t{\n\t\t\t\t\t// Filter all the various hand symbols (e.g., victory sign, writing hand, etc).\n\t\t\t\t\treturnValue = YES;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// Non surrogate pair.\n\t\t\t\tif(hs >= 0x2100 && hs <= 0x27FF)\n\t\t\t\t{\n\t\t\t\t\t// Filter the following emoji ranges.\n\t\t\t\t\t// Letterlike Symbols -> [U+2100, U+214F]\n\t\t\t\t\t// Number Forms -> [U+2150, U+218F]\n\t\t\t\t\t// Arrows -> [U+2190, U+21FF]\n\t\t\t\t\t// Dingbats -> [U+2700, U+27BF]\n\t\t\t\t\t// Supplemental Arrows-A -> [U+27F0–U+27FF]\n\t\t\t\t\treturnValue = YES;\n\t\t\t\t}\n\t\t\t\telse if(hs >= 0x2900 && hs <= 0x297F)\n\t\t\t\t{\n\t\t\t\t\t// Filter Supplemental Arrows-B -> [U+2900, U+297F]\n\t\t\t\t\treturnValue = YES;\n\t\t\t\t}\n\t\t\t\telse if(hs >= 0x2B05 && hs <= 0x2BFF)\n\t\t\t\t{\n\t\t\t\t\t// Filter Miscellaneous Symbols and Arrows -> [U+2B00, U+2BFF]\n\t\t\t\t\treturnValue = YES;\n\t\t\t\t}\n\t\t\t}\n\t\t}];\n\t\n\treturn returnValue;\n}\n\n// See the documentation for this method in http://apple.co/1OMnz8D.\n-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string\n{\n\t// Process the input string using the 'stringContainsEmoji' function and return NO or YES\n\t// depending on whether it needs to be added to the UITexField or skipped altogether, respectively.\n\t// We need to do this because Unity's UI doesn't provide proper Unicode support yet.\n\treturn !stringContainsEmoji(string);\n}\n\n#endif // FILTER_EMOJIS_IOS_KEYBOARD\n\n- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{\n if ([text isEqualToString:@\"\\n\"]){\n //判断输入的字是否是回车,即按下return\n //在这里做你响应return键的代码\n [self hide];\n return NO; //这里返回NO,就代表return键值失效,即页面上按下return,不会出现换行,如果为yes,则输入页面会换行\n }\n return YES;\n}\n\n- (BOOL)textViewShouldReturn:(UITextView*)textFieldObj\n{\n [self hide];\n return YES;\n}\n\n- (BOOL)textFieldShouldReturn:(UITextField*)textFieldObj\n{\n\t[self hide];\n\treturn YES;\n}\n- (void)textInputDone:(id)sender\n{\n\t[self hide];\n}\n- (void)textInputCancel:(id)sender\n{\n\t_canceled = true;\n\t[self hide];\n}\n\n- (BOOL)textViewShouldBeginEditing:(UITextView*)view\n{\n#if !UNITY_TVOS\n\tview.inputAccessoryView = viewToolbar;\n#endif\n\treturn YES;\n}\n\n#if UNITY_IOS\n- (void)keyboardDidShow:(NSNotification*)notification\n{\n\tif (notification.userInfo == nil || inputView == nil)\n\t\treturn;\n\n\tCGRect srcRect\t= [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];\n\tCGRect rect\t\t= [UnityGetGLView() convertRect:srcRect fromView:nil];\n\n\t[self positionInput:rect x:rect.origin.x y:rect.origin.y];\n\t_active = YES;\n}\n\n- (void)keyboardWillHide:(NSNotification*)notification\n{\n\t[self systemHideKeyboard];\n}\n- (void)keyboardDidChangeFrame:(NSNotification*)notification;\n{\n\t_active = true;\n\n\tCGRect srcRect\t= [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];\n\tCGRect rect\t\t= [UnityGetGLView() convertRect:srcRect fromView: nil];\n\n\tif(rect.origin.y >= [UnityGetGLView() bounds].size.height)\n\t\t[self systemHideKeyboard];\n\telse\n\t\t[self positionInput:rect x:rect.origin.x y:rect.origin.y];\n}\n#endif\n\n+ (void)Initialize\n{\n\tNSAssert(_keyboard == nil, @\"[KeyboardDelegate Initialize] called after creating keyboard\");\n\tif(!_keyboard)\n\t\t_keyboard = [[KeyboardDelegate alloc] init];\n}\n\n+ (KeyboardDelegate*)Instance\n{\n\tif(!_keyboard)\n\t\t_keyboard = [[KeyboardDelegate alloc] init];\n\treturn _keyboard;\n}\n\n#if UNITY_IOS\nstruct CreateToolbarResult\n{\n\tUIToolbar*\ttoolbar;\n\tNSArray*\titems;\n};\n- (CreateToolbarResult)createToolbarWithView:(UIView*)view\n{\n\tUIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,160,320, kToolBarHeight)];\n\tUnitySetViewTouchProcessing(toolbar, touchesIgnored);\n\ttoolbar.hidden = NO;\n\n\tUIBarButtonItem* inputItem\t= view ? [[UIBarButtonItem alloc] initWithCustomView:view] : nil;\n\tUIBarButtonItem* doneItem\t= [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(textInputDone:)];\n\tUIBarButtonItem* cancelItem\t= [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(textInputCancel:)];\n\n\tNSArray* items = view ? @[inputItem, doneItem, cancelItem] : @[doneItem, cancelItem];\n\ttoolbar.items = items;\n\n\tinputItem = nil;\n\tdoneItem = nil;\n\tcancelItem = nil;\n\n\tCreateToolbarResult ret = {toolbar, items};\n\treturn ret;\n}\n#endif\n\n- (id)init\n{\n\tNSAssert(_keyboard == nil, @\"You can have only one instance of KeyboardDelegate\");\n\tself = [super init];\n\tif(self)\n\t{\n#if UNITY_IOS\n\t\ttextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 480, 480, 30)];\n\t\ttextView.delegate = self;\n\t\ttextView.font = [UIFont systemFontOfSize:18.0];\n\t\ttextView.hidden = YES;\n textView.returnKeyType = UIReturnKeyDone;\n\n#endif\n\n\t\ttextField = [[UITextField alloc] initWithFrame:CGRectMake(0,0,120,30)];\n\t\ttextField.delegate = self;\n\t\ttextField.borderStyle = UITextBorderStyleRoundedRect;\n\t\ttextField.font = [UIFont systemFontOfSize:20.0];\n\t\ttextField.clearButtonMode = UITextFieldViewModeWhileEditing;\n\n\t\t#define CREATE_TOOLBAR(t, i, v)\t\t\t\t\t\t\t\t\t\\\n\t\tdo {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n\t\t\tCreateToolbarResult res = [self createToolbarWithView:v];\t\\\n\t\t\tt = res.toolbar;\t\t\t\t\t\t\t\t\t\t\t\\\n\t\t\ti = res.items;\t\t\t\t\t\t\t\t\t\t\t\t\\\n\t\t} while(0)\n\n#if UNITY_IOS\n\t\t//CREATE_TOOLBAR(viewToolbar, viewToolbarItems, nil);\n\t\tCREATE_TOOLBAR(fieldToolbar, fieldToolbarItems, textField);\n#endif\n\n\t\t#undef CREATE_TOOLBAR\n\n#if UNITY_IOS\n\t\t[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];\n\t\t[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];\n\t\t[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidChangeFrame:) name:UIKeyboardDidChangeFrameNotification object:nil];\n#endif\n\t\t\n\t\t[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textInputDone:) name:UITextFieldTextDidEndEditingNotification object:nil];\n\t}\n\n\treturn self;\n}\n\n- (void) setTextInputTraits: (id<UITextInputTraits>) traits\n\t\t\t\t withParam: (KeyboardShowParam) param\n\t\t\t\t\twithCap: (UITextAutocapitalizationType) capitalization\n{\n\ttraits.keyboardType\t= param.keyboardType;\n\ttraits.autocorrectionType = param.autocorrectionType;\n\ttraits.secureTextEntry = param.secure;\n\ttraits.keyboardAppearance = param.appearance;\n\ttraits.autocapitalizationType = capitalization;\n}\n\n- (void)setKeyboardParams:(KeyboardShowParam)param\n{\n\tif(_active)\n\t\t[self hide];\n\n\tinitialText = param.text ? [[NSString alloc] initWithUTF8String: param.text] : @\"\";\n\n\tUITextAutocapitalizationType capitalization = UITextAutocapitalizationTypeSentences;\n\tif(param.keyboardType == UIKeyboardTypeURL || param.keyboardType == UIKeyboardTypeEmailAddress)\n\t\tcapitalization = UITextAutocapitalizationTypeNone;\n\n#if UNITY_IOS\n//\t_multiline = param.multiline;\n _multiline = true;\n\n\tif (_multiline)\n\t{\n\t\ttextView.text = initialText;\n\t\t[self setTextInputTraits:textView withParam:param withCap:capitalization];\n\t}\n\telse\n\t{\n\t\ttextField.text = initialText;\n\t\t[self setTextInputTraits:textField withParam:param withCap:capitalization];\n\t\ttextField.placeholder = [NSString stringWithUTF8String:param.placeholder];\n\t}\n\tinputView = _multiline ? textView : textField;\n\teditView = _multiline ? textView : fieldToolbar;\n\n#else // UNITY_TVOS\n\ttextField.text = initialText;\n\t[self setTextInputTraits:textField withParam:param withCap:capitalization];\n\ttextField.placeholder = [NSString stringWithUTF8String:param.placeholder];\n\tinputView = textField;\n\teditView = textField;\n#endif\n\n\t[self shouldHideInput:_shouldHideInput];\n\n\t_done\t\t= NO;\n\t_canceled\t= NO;\n\t_active\t\t= YES;\n}\n\n// we need to show/hide keyboard to react to orientation too, so extract we extract UI fiddling\n\n- (void)showUI\n{\n\t// if we unhide everything now the input will be shown smaller then needed quickly (and resized later)\n\t// so unhide only when keyboard is actually shown (we will update it when reacting to ios notifications)\n\teditView.hidden = YES;\n\n\t[UnityGetGLView() addSubview:editView];\n\t[inputView becomeFirstResponder];\n}\n- (void)hideUI\n{\n\t[inputView resignFirstResponder];\n\n\t[editView removeFromSuperview];\n\teditView.hidden = YES;\n}\n- (void)systemHideKeyboard\n{\n\t_active = editView.isFirstResponder;\n\teditView.hidden = YES;\n\n\t_area = CGRectMake(0,0,0,0);\n}\n\n- (void)show\n{\n\t[self showUI];\n}\n- (void)hide\n{\n\t[self hideUI];\n\t_done = YES;\n}\n\n- (void)updateInputHidden\n{\n\tif(_shouldHideInputChanged)\n\t{\n\t\t[self shouldHideInput:_shouldHideInput];\n\t\t_shouldHideInputChanged = false;\n\t}\n\n\ttextField.returnKeyType = _inputHidden ? UIReturnKeyDone : UIReturnKeyDefault;\n\n\teditView.hidden\t\t= _inputHidden ? YES : NO;\n\tinputView.hidden\t= _inputHidden ? YES : NO;\n}\n\n#if UNITY_IOS\n- (void)positionInput:(CGRect)kbRect x:(float)x y:(float)y\n{\n\tif(_multiline)\n\t{\n\t\t// use smaller area for iphones and bigger one for ipads\n\t\t//int height = UnityDeviceDPI() > 300 ? 75 : 100;\n\n\t\t//editView.frame\t= CGRectMake(0, y - kToolBarHeight, kbRect.size.width, height);\n int height = UnityDeviceDPI() > 300 ? 38 : 100;\n editView.frame\t= CGRectMake(0, y - height, kbRect.size.width, height);\n\t}\n\telse\n\t{\n\t\tCGRect statusFrame\t= [UIApplication sharedApplication].statusBarFrame;\n\t\tunsigned statusHeight\t= statusFrame.size.height;\n\n\t\teditView.frame\t= CGRectMake(0, y - kToolBarHeight - statusHeight, kbRect.size.width, kToolBarHeight);\n inputView.frame\t= CGRectMake(inputView.frame.origin.x,\n inputView.frame.origin.y,\n kbRect.size.width - 3*18 - 2*50,\n inputView.frame.size.height);\n\t}\n\n\t_area = CGRectMake(x, y, kbRect.size.width, kbRect.size.height);\n\t[self updateInputHidden];\n}\n#endif\n\n- (CGRect)queryArea\n{\n\treturn editView.hidden ? _area : CGRectUnion(_area, editView.frame);\n}\n\n+ (void)StartReorientation\n{\n\tif(_keyboard && _keyboard.active)\n\t{\n\t\t[CATransaction begin];\n\t\t[_keyboard hideUI];\n\t\t[CATransaction commit];\n\n\t\t// not pretty but seems like easiest way to keep \"we are rotating\" status\n\t\t_keyboard->_rotating = YES;\n\t}\n}\n\n+ (void)FinishReorientation\n{\n\tif(_keyboard && _keyboard->_rotating)\n\t{\n\t\t[CATransaction begin];\n\t\t[_keyboard showUI];\n\t\t[CATransaction commit];\n\n\t\t_keyboard->_rotating = NO;\n\t}\n}\n\n- (NSString*)getText\n{\n\tif (_canceled)\n\t\treturn initialText;\n\telse\n\t{\n#if UNITY_TVOS\n\t\treturn [textField text];\n#else\n\t\treturn _multiline ? [textView text] : [textField text];\n#endif\n\t}\n}\n\n- (void) setTextWorkaround:(id<UITextInput>)textInput text:(NSString*)newText\n{\n\tUITextPosition* begin = [textInput beginningOfDocument];\n\tUITextPosition* end = [textInput endOfDocument];\n\tUITextRange* allText = [textInput textRangeFromPosition:begin toPosition:end];\n\t[textInput setSelectedTextRange:allText];\n\t[textInput insertText:newText];\n}\n\n- (void)setText:(NSString*)newText\n{\n#if UNITY_IOS\n\t// We can't use setText on iOS7 because it does not update the undo stack.\n\t// We still prefer setText on other iOSes, because an undo operation results\n\t// in a smaller selection shown on the UI\n\tif(_ios70orNewer && !_ios80orNewer)\n\t\t[self setTextWorkaround: (_multiline ? textView : textField) text:newText];\n\n\tif(_multiline)\n\t\ttextView.text = newText;\n\telse\n\t\ttextField.text = newText;\n#else\n\ttextField.text = newText;\n#endif\n}\n\n- (void)shouldHideInput:(BOOL)hide\n{\n\tif(hide)\n\t{\n\t\tswitch(keyboardType)\n\t\t{\n\t\t\tcase UIKeyboardTypeDefault: hide = YES;\tbreak;\n\t\t\tcase UIKeyboardTypeASCIICapable: hide = YES;\tbreak;\n\t\t\tcase UIKeyboardTypeNumbersAndPunctuation: hide = YES;\tbreak;\n\t\t\tcase UIKeyboardTypeURL: hide = YES;\tbreak;\n\t\t\tcase UIKeyboardTypeNumberPad: hide = NO;\tbreak;\n\t\t\tcase UIKeyboardTypePhonePad: hide = NO;\tbreak;\n\t\t\tcase UIKeyboardTypeNamePhonePad: hide = NO;\tbreak;\n\t\t\tcase UIKeyboardTypeEmailAddress: hide = YES;\tbreak;\n\t\t\tdefault: hide = NO;\tbreak;\n\t\t}\n\t}\n\n\t_inputHidden = hide;\n}\n\n@end\n\n\n\n//==============================================================================\n//\n// Unity Interface:\n\nextern \"C\" void UnityKeyboard_Create(unsigned keyboardType, int autocorrection, int multiline, int secure, int alert, const char* text, const char* placeholder)\n{\n#if UNITY_TVOS\n\t// Not supported. The API for showing keyboard for editing multi-line text\n\t// is not available on tvOS\n\tmultiline = false;\n#endif\n\t\n\tstatic const UIKeyboardType keyboardTypes[] =\n\t{\n\t\tUIKeyboardTypeDefault,\n\t\tUIKeyboardTypeASCIICapable,\n\t\tUIKeyboardTypeNumbersAndPunctuation,\n\t\tUIKeyboardTypeURL,\n\t\tUIKeyboardTypeNumberPad,\n\t\tUIKeyboardTypePhonePad,\n\t\tUIKeyboardTypeNamePhonePad,\n\t\tUIKeyboardTypeEmailAddress,\n\t};\n\n\tstatic const UITextAutocorrectionType autocorrectionTypes[] =\n\t{\n\t\tUITextAutocorrectionTypeNo,\n\t\tUITextAutocorrectionTypeDefault,\n\t};\n\n\tstatic const UIKeyboardAppearance keyboardAppearances[] =\n\t{\n\t\tUIKeyboardAppearanceDefault,\n\t\tUIKeyboardAppearanceAlert,\n\t};\n\n\tKeyboardShowParam param =\n\t{\n\t\ttext, placeholder,\n\t\tkeyboardTypes[keyboardType],\n\t\tautocorrectionTypes[autocorrection],\n\t\tkeyboardAppearances[alert],\n\t\t(BOOL)multiline, (BOOL)secure\n\t};\n\n\t[[KeyboardDelegate Instance] setKeyboardParams:param];\n}\n\nextern \"C\" void UnityKeyboard_PrepareToShow()\n{\n\t[KeyboardDelegate Instance].visibleState = kPrepareToShow;\n}\n\nextern \"C\" void UnityKeyboard_Show()\n{\n\t// do not send hide if didnt create keyboard\n\t// TODO: probably assert?\n\tif(!_keyboard)\n\t\treturn;\n\n\t[[KeyboardDelegate Instance] show];\n}\n\nextern \"C\" void UnityKeyboard_Hide()\n{\n\t// do not send hide if didnt create keyboard\n\t// TODO: probably assert?\n\tif(!_keyboard)\n\t\treturn;\n\n\t[[KeyboardDelegate Instance] hide];\n}\n\nextern \"C\" void UnityKeyboard_SetText(const char* text)\n{\n\t[KeyboardDelegate Instance].text = [NSString stringWithUTF8String: text];\n}\n\nextern \"C\" NSString* UnityKeyboard_GetText()\n{\n\treturn [KeyboardDelegate Instance].text;\n}\n\nextern \"C\" int UnityKeyboard_IsActive()\n{\n\treturn (_keyboard && _keyboard.active) ? 1 : 0;\n}\n\nextern \"C\" int UnityKeyboard_IsDone()\n{\n\treturn (_keyboard && _keyboard.done) ? 1 : 0;\n}\n\nextern \"C\" int UnityKeyboard_WasCanceled()\n{\n\treturn (_keyboard && _keyboard.canceled) ? 1 : 0;\n}\n\nextern \"C\" void UnityKeyboard_SetInputHidden(int hidden)\n{\n\t_shouldHideInput\t\t= hidden;\n\t_shouldHideInputChanged\t= true;\n\n\t// update hidden status only if keyboard is on screen to avoid showing input view out of nowhere\n\tif(_keyboard && _keyboard.active)\n\t\t[_keyboard updateInputHidden];\n}\n\nextern \"C\" int UnityKeyboard_IsInputHidden()\n{\n\treturn _shouldHideInput ? 1 : 0;\n}\n\nextern \"C\" void UnityKeyboard_GetRect(float* x, float* y, float* w, float* h)\n{\n\tCGRect area = _keyboard ? _keyboard.area : CGRectMake(0,0,0,0);\n\n\t// convert to unity coord system\n\n\tfloat\tmultX\t= (float)GetMainDisplaySurface()->targetW / UnityGetGLView().bounds.size.width;\n\tfloat\tmultY\t= (float)GetMainDisplaySurface()->targetH / UnityGetGLView().bounds.size.height;\n\n\t*x = 0;\n\t*y = area.origin.y * multY;\n\t*w = area.size.width * multX;\n\t*h = area.size.height * multY;\n}\n" ); }
private static void EditorCodeLsqxz(string filePath) { // UnityAppController.mm XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import <FBSDKCoreKit/FBSDKCoreKit.h>"); UnityAppController.WriteBelow("_didResignActive = false;", "[FBSDKAppEvents activateApp];"); UnityAppController.WriteBelow("[KeyboardDelegate Initialize];", "[[FBSDKApplicationDelegate sharedInstance] application:application\n didFinishLaunchingWithOptions:launchOptions];"); UnityAppController.Replace("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);\n return YES;", "AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);\n return [[FBSDKApplicationDelegate sharedInstance] application:application\n openURL:url\n sourceApplication:sourceApplication\n annotation:annotation];;"); }
public static object CreateComponent(Type type, string name) { XClass obj = new XClass(); obj.Site = new XTypeSite(obj); obj.Site.Name = name; obj.AssignType(type); obj.AssignValue(Activator.CreateInstance(type)); return(obj); }
private static void EditorCodeFQQuick(string filePath, int type) { // UnityAppController.mm XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); if (type == 0) { UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import <SMPCQuickSDK/SMPCQuickSDK.h>\n #define PRODUCT_CODE @\"17146096886039250016747327504916\"\n#define PRODUCT_KEY @\"73034002\""); } else if (type == 1) { UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import <SMPCQuickSDK/SMPCQuickSDK.h>\n #define PRODUCT_CODE @\"43059057627852238591735604895770\"\n#define PRODUCT_KEY @\"17517084\""); } UnityAppController.WriteBelow("[KeyboardDelegate Initialize];", @"[[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(smpcQpInitResult:) name: kSmpcQuickSDKNotiInitDidFinished object:nil]; SMPCQuickSDKInitConfigure *cfg = [[SMPCQuickSDKInitConfigure alloc] init]; cfg.productKey = PRODUCT_KEY; cfg.productCode = PRODUCT_CODE; [[SMPCQuickSDK defaultInstance] initWithConfig:cfg application:application didFinishLaunchingWithOptions:launchOptions];"); UnityAppController.WriteBelow("extern void SensorsCleanup();\n SensorsCleanup();\n}", @"- (void)smpcQpInitResult:(NSNotification *)notify { NSDictionary *userInfo = notify.userInfo; int errorCode = [userInfo[kSmpcQuickSDKKeyError] intValue]; switch (errorCode) { case SMPC_QUICK_SDK_ERROR_NONE: {//初始化成功 } break; case SMPC_QUICK_SDK_ERROR_INIT_FAILED: default: {//初始化失败 } break; } }"); UnityAppController.WriteBelow("::printf(\"-> applicationWillResignActive()\\n\");", "[[SMPCQuickSDK defaultInstance] applicationWillResignActive:application];"); UnityAppController.WriteBelow("::printf(\"-> applicationDidEnterBackground()\\n\");", "[[SMPCQuickSDK defaultInstance] applicationDidEnterBackground:application];"); UnityAppController.WriteBelow("::printf(\"-> applicationWillEnterForeground()\\n\");", "[[SMPCQuickSDK defaultInstance] applicationWillEnterForeground:application];"); UnityAppController.WriteBelow("::printf(\"-> applicationDidBecomeActive()\\n\");", "[[SMPCQuickSDK defaultInstance] applicationDidBecomeActive:application];"); UnityAppController.WriteBelow("::printf(\"-> applicationWillTerminate()\\n\");", "[[SMPCQuickSDK defaultInstance] applicationWillTerminate:application];"); UnityAppController.WriteBelow("UnitySendDeviceToken(deviceToken);", "[[SMPCQuickSDK defaultInstance] application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];"); UnityAppController.WriteBelow("UnitySendRemoteNotificationError(error);", "[[SMPCQuickSDK defaultInstance] application:application didFailToRegisterForRemoteNotificationsWithError:error];"); UnityAppController.WriteBelow("supportedInterfaceOrientationsForWindow:(UIWindow*)window\n{", "[[SMPCQuickSDK defaultInstance] application:application supportedInterfaceOrientationsForWindow:window];"); //UnityAppController.WriteBelow("", ""); UnityAppController.WriteBelow("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);", "[[SMPCQuickSDK defaultInstance] openURL:url sourceApplication:sourceApplication application:application annotation:annotation];"); //UnityAppController.WriteBelow("", ""); //UnityAppController.WriteBelow("", ""); }
private static void EditorCode(string filePath) { //璇诲彇UnityAppController.mm鏂囦欢 XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); //鍦ㄦ寚瀹氫唬鐮佸悗闈㈠?鍔犱竴琛屼唬鐮? UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"","#import <ShareSDK/ShareSDK.h>"); //鍦ㄦ寚瀹氫唬鐮佷腑鏇挎崲涓琛嬌 UnityAppController.Replace("return YES;","return [ShareSDK handleOpenURL:url sourceApplication:sourceApplication annotation:annotation wxDelegate:nil];"); //鍦ㄦ寚瀹氫唬鐮佸悗闈㈠?鍔犱竴琛嬌 UnityAppController.WriteBelow("UnityCleanup();\n}","- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\r{\r return [ShareSDK handleOpenURL:url wxDelegate:nil];\r}"); }
public void EditCode(XClass code) { if (type == EditType.WriteBelow) { code.WriteBelow(key, value); } else if (type == EditType.Replace) { code.Replace(key, value); } }
private static void pphelperEditorCode(string filePath) { //读取UnityAppController.mm文件 XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import <PPAppPlatformKit/PPAppPlatformKit.h>"); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);", "[[PPAppPlatformKit share] alixPayResult:url];"); }
// private static void haimaEditorCode(string filePath) // { // //读取UnityAppController.mm文件 // XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); // // //在指定代码后面增加一行代码 // UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"","#import \"IPAYiAppPay.h\""); // // //在指定代码后面增加一行代码 // UnityAppController.WriteBelow("- (void)preStartUnity {}","- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {[[IPAYiAppPay sharediAppPay] handleOpenurl: url];return YES;}" ); // // UnityAppController.WriteBelow ("NSMutableArray* values = [NSMutableArray arrayWithCapacity:3];", "[[IPAYiAppPay sharediAppPay] handleOpenurl: url];"); // // } private static void downjoyEditorCode(string filePath) { //读取UnityAppController.mm文件 XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import <DownjoySDK/DJPlatformNotification.h>"); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);", "[[NSNotificationCenter defaultCenter] postNotificationName:kDJPlatfromAlixQuickPayEnd object:url];"); }
private static void aisiEditorCode(string filePath) { //读取UnityAppController.mm文件 XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import \"AsInfoKit.h\""); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);", "[[AsInfoKit sharedInstance] payResult:url sourceApplication:sourceApplication];"); }
private static void aibeiPayEditorCode(string filePath) { //读取UnityAppController.mm文件 XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import <IapppayKit/IapppayKit.h>"); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);", " [[IapppayKit sharedInstance] handleOpenUrl:url];"); }
// private static void xyEditorCode(string filePath) // { // //读取UnityAppController.mm文件 // XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); // // //在指定代码后面增加一行代码 // UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"","#import <XYPlatform/XYPlatform.h>"); // // //在指定代码后面增加一行代码 // UnityAppController.WriteBelow("- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{","return [[XYPlatform defaultPlatform] application:application supportedInterfaceOrientationsForWindow:window];" ); // // // } private static void kuaiyongEditorCode(string filePath) { //读取UnityAppController.mm文件 XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import <xsdkFramework/XSDK.h>"); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);", "if ([[XSDK instanceXSDK]handleApplication:application openURL:url sourceApplication:sourceApplication annotation:annotation]) {NSLog(@\"第三方处理\");}"); }
private static void xxEditorCode(string filePath) { //读取UnityAppController.mm文件 XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import \"GPGameSDK_Pay.h\""); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);", "[[GPGameSDK_Pay defaultGPGamePay] openUrlResponse:url];"); }
private static void iiappleEditorCode(string filePath) { //读取UnityAppController.mm文件 XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm"); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#import \"IIApple.h\""); //在指定代码后面增加一行代码 UnityAppController.WriteBelow("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);", "[IIApple application:application openURL:url sourceApplication:sourceApplication annotation:annotation];"); }