I have an iOS app, with diffrent views, and I would like to open a Unity project on click of a button. This would be an augmented reality part of the App, which thus uses the qualcomm plugin for Unity. I followed the guide http://alexanderwong.me/post/29949258838/building-a-ios-unity-uiview-uiviewcontroller as much as possible, but have a few problems
Ideally, I would like to load Unity on the touch of the button, not on AppStart, I have the method that get calls when the button is touched, but honestly have no idea what should go there
UnityPause: NO
??If not possible to load Unity at Button click, then at it should be loaded on application: didFinishLaunchingWithOptions:, and, as in the guide, I call the AppController window from AppDelegate ..
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions: (NSDictionary*)launchOptions { //unity BOOL returnBOOL; if (_unityController == nil) { _unityController = [[AppController alloc] init]; } returnBOOL = [_unityController application:application didFinishLaunchingWithOptions:launchOptions]; //other app-loading things here... CGRect screenBounds = [[UIScreen mainScreen] bounds]; self.window = [[UIWindow alloc] initWithFrame:screenBounds]; self.window.autoresizesSubviews = YES; NSLog(@"Will start loading Unity window"); // unity, set window window = [_unityController window]; //App crashes here // navigation controller [window addSubview:navigationController.view]; self.viewController = [[MainViewController alloc] init]; self.viewController.useSplashScreen = YES; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; //more loading things.... return returnBOOL; }
and then on AppController.mm I have:
- (UIWindow *)window
{
return _window;
}
This throws me a compiler error "Use of undeclared identifier _window", ok, I get this is wrong, he doesn't know where _window comes from.. but what I dont know, is where it should come from.. and I don't really know how to fix this.
And lastly, for performance reasons, if I had to load Unity only at button click, what should get called there? (Unity takes very long to load, I'm not really sure if it's better to load it at AppStart, or at Button Click, (won't it look wierd if you click the button, and it takes long to open the camera?).. any help would be apreciated!
Thanks! :)