#import #import "ISN_NativeCore.h" #import "AppDelegateListener.h" @implementation ISN_DataConvertor +(NSString *) charToNSString:(char *)value { if (value != NULL) { return [NSString stringWithUTF8String: value]; } else { return [NSString stringWithUTF8String: ""]; } } + (const char *) NSStringToChar:(NSString *)value { return [value UTF8String]; } @end @implementation ISN_NativeUtility static bool logState = false; static ISN_NativeUtility * na_sharedInstance; + (id)sharedInstance { if (na_sharedInstance == nil) { na_sharedInstance = [[self alloc] init]; } return na_sharedInstance; } + (BOOL) IsIPad { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { return true; } else { return false; } } + (int) majorIOSVersion { NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; return [[vComp objectAtIndex:0] intValue]; } -(void) ISN_SetLogState:(BOOL)state { logState = state; } -(void) ISN_NativeLog:(NSString *)msg, ... { if(logState) { va_list argumentList; va_start(argumentList, msg); NSString *message = [[NSString alloc] initWithFormat:msg arguments:argumentList]; // clean up va_end(argumentList); NSLog(@"ISN_NativeLog: %@", message); } } - (CGFloat) GetW { UIViewController *vc = UnityGetGLViewController(); bool IsLandscape = true; #if !TARGET_OS_TV UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { IsLandscape = true; } else { IsLandscape = false; } #endif CGFloat w; if(IsLandscape) { w = vc.view.frame.size.height; } else { w = vc.view.frame.size.width; } NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; if ([[vComp objectAtIndex:0] intValue] >= 8) { w = vc.view.frame.size.width; } return w; } @end