First off, thanks to Gregg Patton and his blog post for inspiring this plugin. This has only been tested with Unity 3 beta. Second, all relevant code is available on GitHub. The relevant folders are NativeBinding, NativeCode and for a test project look in the TestScenes folder.
This plugin makes it dead easy to integrate UIKit with Unity for pause menus, level selection, cut scene navigation, etc. UIKit makes creating menu systems and settings panes a breeze compared to in Unity and this plugin aims to fill the gap.
The basic gist of the usage is really simple and flexible. You can either go with all the defaults for the UnityNativeManager or in your Xcode project just set them once and they will hold for the duration of the game. The interesting properties and methods for customizing the animations are:
CAMediaTimingFunction *animationTimingFunction // available options are the usual bag: easeIn, easeOut, easeInOut, easeOutIn
CFTimeInterval animationDuration; // duration of the animation
// set the specific animation (and subtype if applicable). See the header for all available types and subTypes.
- (void)setAnimationType:(NSString*)animationType subtype:(NSString*)animationSubtype;
From Objective-C, you can easily call a few built in methods or add your own. The UnityGameController.cs script has some common methods callable from Obj-C such as: loadLevel, loadLevelAdditive, loadLevelAsync, loadLevelAdditiveAsync. All you need to do to load a level additive async from Obj-C is the following:
[[UnityNativeManager sharedManager] pauseUnity:NO];
UnitySendMessage( "UnityGameController", "loadLevelAdditiveAsync", [@"PartialScene" UTF8String
] );
From the Unity side of things all you need to do to get a viewController up and running is call the following method:
UIBinding.activateUIWithController( "TestViewController" );
If your view controllers are setup with nib files this will take care of instantiating them with the nibs. It will also take care of pausing Unity and animating the view controller in. To dismiss the view controller and unpause Unity just call:
[[UnityNativeManager sharedManager] hideViewControllerAndRestartUnity];
For anyone who knows a bit about Cocoa/Objective-C or anyone willing to learn just the very basics this will make creating really nice menu systems a breeze.
Enjoy!