По вашему запросу я загрузил видеоурок по созданию Unity в родном приложении для iOS с последней версией Xcode-10.1 и unity -2018.2.18f1.
Ссылка на Youtube- https://www.youtube.com/watch?v=DLkeGz5vCzk
Исходный код для Делегата приложения:
AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIWindow *unityWindow;
@property (strong, nonatomic) UnityAppController *unityController;
- (void) showUnityWindow;
- (void) hideUnityWindow;
@end
AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (UIWindow *)unityWindow {
return UnityGetMainWindow();
}
- (void) showUnityWindow {
[self.unityWindow makeKeyAndVisible];
}
- (void) hideUnityWindow{
[self.window makeKeyAndVisible];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen]. bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ViewController *mainVC = [storyboard instantiateViewControllerWithIdentifier:@"MainIdentity"];
UINavigationController *naVC = [[UINavigationController alloc] initWithRootViewController:mainVC];
self.window.rootViewController = naVC;
self.unityController = [[UnityAppController alloc] init];
[self.unityController application:application didFinishLaunchingWithOptions: launchOptions];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
[self.unityController applicationWillResignActive:application];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
[self.unityController applicationDidEnterBackground:application];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
[self.unityController applicationWillEnterForeground:application];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[self.unityController applicationDidBecomeActive:application];
}
- (void)applicationWillTerminate:(UIApplication *)application {
[self.unityController applicationWillTerminate:application];
}
@end
And View Controller.m
#import "ViewController.h"
#import "AppDelegate.h"
@interface ViewController ()
@property (nonatomic) BOOL isShowUnityWindow;
- (IBAction)showUnityTouched:(id)sender;
@property (weak, nonatomic) IBOutlet UIView *unityViewStart;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.isShowUnityWindow = NO;
}
- (IBAction)showUnityTouched:(id)sender {
self.isShowUnityWindow = !self.isShowUnityWindow;
AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
if (self.isShowUnityWindow) {
[appDelegate.unityWindow setFrame:CGRectMake(40, 200, 500, 500)];
[appDelegate.unityWindow ]
[appDelegate showUnityWindow];
}
else {
[appDelegate hideUnityWindow];
}
}
@end