title: Activating Unity on iOS Button click
body: <p>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 <a href="http://alexanderwong.me/post/29949258838/building-a-ios-unity-uiview-uiviewcontroller" rel="nofollow">http://alexanderwong.me/post/29949258838/building-a-ios-unity-uiview-uiviewcontroller</a> as much as possible, but have a few problems</p>
  
  <ol>
  <li><p>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 <code> UnityPause: NO </code>??</p></li>
  <li><p>If not possible to load Unity at Button click, then at it should be loaded on <em>application: didFinishLaunchingWithOptions:</em>, and, as in the guide, I call the AppController window from AppDelegate .. </p>
  
  <pre><code>- (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;
  }
  </code></pre></li>
  </ol>
  
  <p>and then on AppController.mm I have:</p>
  
  <pre><code>- (UIWindow *)window
  {
  return _window; 
  }
  </code></pre>
  
  <p>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 <em>should</em> come from.. and I don't really know how to fix this. </p>
  
  <p>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!</p>
  
  <p>Thanks! :) </p>