Get Your Cocoa On Integrating Objective-C into Unity iPhone Apps Brian Robbins President/Founder – Riptide Games Slides & Source Code: Unity Unite – October 30, 2009
Overview Background Creating views Messaging Pros & Cons Q&A
Why? Use the best technology for what you need Feel like an iPhone app Access to any iPhone feature
Creating Views Demo
Creating Views Key code In ApplicationDidFinishLaunching //Get the application window UIWindow *topWindow = [[[UIApplication sharedApplication] windows] objectAtIndex: [[[UIApplication sharedApplication] windows] count]-1]; myParentView.center = topWindow.center;[topWindow addSubview:myParentView]; //Next create the MenuViewController menuVC = [[MenuViewController alloc] bundle:nil]; //Add it to the window so it can be active//Now we can add our Menu to the landscape View and it will appear [myParentView addSubview:menuVC.view];
Messaging Demo
Messaging Overview Poll NSUserDefaults for message from Unity Poll PlayerPrefs.GetString for message from Cocoa
Limitations Speed? One message per Unity update Text only, no binary
Pros Do anything you want on iPhone Feel like a native iPhone app Faster menu design & iteration Separate workload
Cons Extra work to test in Unity Limitations of message system Fragile vs future Unity updates
What is enabled Cocoa menus In App Purchase Video playback Different sound control OpenFeint, Plus+, etc. integration AdMob, etc. PinchMedia, Localytics, etc. Anything else you want!
Final Thoughts Pretty straightforward and lightweight Make menus & UI native iPhone Use Enhancement Pack frontend-for-unity-iphone-applications/
Q & A Brian Robbins President/Founder – Riptide Games Slides & Source Code: