I have a xCode project generated by Unity3D (which includes a animation) and I’ve integrated vuforia SDK for displaying an animation (Augmented reality)
The issue that I got by now is to add the navigation between the camera screen and the dashboard of my app.
In int OpenEAGL_UnityCallback(UIWindow** window, int* screenWidth, int* screenHeight, int* openglesVersion) method I’m adding the back button pragmatically like:
if (wrapperObj == nil)
{
wrapperObj = [[WrapperClass alloc] init];
}
[backButton addTarget:wrapperObj action:@selector(goToDashBoard:) forControlEvents:UIControlEventTouchUpInside];
Pass it to a wrapper class
@interface WrapperClass : NSObject
@property (nonatomic, retain) UINavigationController *navigation;
-(void)goToDashBoard:(UIButton*)sender;
@end
void goToPreviousScreen()
{
}
@implementation WrapperClass
@synthesize navigation;
-(void) goToDashBoard:(UIButton*)sender
{
[[self navigation] popViewControllerAnimated:YES];
goToPreviousScreen();
}
@end
Can anyone point me to a solution how to make the navigation up and running?
UPDATE
When trying to pop the view in this way:
AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate.navigationController popToRootViewControllerAnimated:YES];
I get this log:
2012-12-05 16:20:45.502 arapp[5993:907] <HomeViewController: 0x246db00>
StopQCAR
(Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)
Could not deactivate dataset.
(Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)
Could not destroy dataset.
(Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)
Could not deinitialize the tracker.
(Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)
Could not deinitialize the tracker.
(Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)
ghashtable.c:294: assertion 'hash != NULL' failed
If I understand your question correctly you are trying to modify the Unity built Xcode project by adding files, viewcontrollers, code, etc. to it. It’s been my experience that this is not a good idea and you may be much better off building your app in Unity as much as possible. The moderators on Vuforia’s forum strongly discourage it also. I built a Unity/Vuforia app this way, mostly to avoid spending the time learning how to do it in Unity with C#. I ended up with a memory leak I couldn’t track down and had to bite the bullet and go back to Unity and learn Unity scripting. Of course there are many iOS things you can’t do in Unity, and I have no idea what your app does, but there are many plugins that can help you, and I ended learning how to write my own plugins to get some iOS functionality I needed.
However, if you want to navigate between the AR view and other view controllers the way I did it was by making another viewController that was basically an overlay and contained just the button for navigation. Then I initialized it and added it as a subview to the UnityViewController. Then you add the code to go to whatever view you want, like your dashboard.
As you may know you can comment out startUnity() in the AppController to prevent the AR view from coming up when the app starts, and call it in another VC to get back to the AR view. This approach let me navigate between the AR view and several other VC’s, but ultimately the app was unstable and had to be replaced with one built entirely in Unity. Maybe you can find a better way, but you may be better off diving into Unity and plugins, depending on what you want your app to do. Hope this helps.