#import #import #include #include extern "C" UIViewController *UnityGetGLViewController(void); extern "C" { int AppRuntimes_GetEnableUnityLog() { id value = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"EnableUnityLog"]; if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]]) return [value boolValue] ? 1 : 0; return 0; } const char *AppRuntimes_GetTestUserID() { id value = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"TestUserID"]; return strdup([value isKindOfClass:[NSString class]] ? [value UTF8String] : ""); } void AppRuntimes_FreeString(const char *value) { free((void *)value); } void AppRuntimes_ShowDialog(const char *message, void (*callback)(int)) { NSString *text = message ? [NSString stringWithUTF8String:message] : @""; dispatch_async(dispatch_get_main_queue(), ^{ UIViewController *presenter = UnityGetGLViewController(); while (presenter.presentedViewController != nil) presenter = presenter.presentedViewController; if (presenter == nil || presenter.view.window == nil) { callback(0); return; } UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Network Error" message:text preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"Retry" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { callback(1); }]]; [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { callback(0); }]]; [presenter presentViewController:alert animated:YES completion:nil]; }); } }