how can i add a window running Unity, in an xcode project

I am trying to make a desktop app using cocoa and xcode, and would like to have a window running unity inside the main UIView (something like a managerial game, where you have all your buttons and UI items and then you have the 3d window where something happens ); and i need to load dynamically assets into the unity view,based on what happens in the main view.

I wonder if there is a way to add a component to xcode (like UILabel, UIButton, and so on), so i can use it on a xib file and add an outlet so i can drive unity from my main application.


I don’t agree that Unity isn’t “meant for embedding”. Unity’s iPhone build simply creates an iOS application which has it’s own Window, application delegate, etc. They don’t make it easy to do so, but you can embed Unity within another application by forwarding all the application delegate methods from your application’s delegate to those in the unity app delegate. Basically unhook Unity as the application delegate, create an instance of the Unity view controller manually and forward the delegate methods (ex. ApplicationDidFinishLaunching) to your new unity view controller instance.

Depending on your view setup, you can hack the file to get the Unity View controller and use that in your application. For instance, I’ve got a tab bar application where one of the tabs is running Unity. It’s a bit tricky telling Unity when to start and pausing/unpausing when you switch tabs, but it’s totally doable.

In addition, once you have a reference to the Unity view controller, you can use its view just like you would for anything else. You can add sub views (UIKit stuff like buttons for ex.), do layer animations, etc. I’ve got a UIKit toolbar over Unity which looks pretty spiffy as well.

If there’s enough interest in this, I can publish a tutorial. It took me a little while to figure out.

Unity's not really meant for embedding, so I can't think of any trivial answers to this. You could display an HTML page embedded in your application which displays a webplayer, doing Interop via SendMessage. It all seems very convoluted, though.