- Home /
Unity window + iOS window on the same App?
I am building an app for iPad composed of two parts:
a user interface built with cocoa
a Unity scene
And I needed to find a way of integrating both parts and have them communicate with each other.
After a lot of research the best approach that I have found was one based on this tutorial
Basically, I have two UIWindows on my app delegate, one where I keep the hierarchy of all cocoa viewcontrollers and the other is the Unity window. When I want to switch which window is visible I just call [someWindow makeKeyAndVisible];
on the target window. When I need to communicate from the cocoa side to Unity I call UnitySendMessage
.
This approach seems to work fairly well in the beginning but as I play with my app and after switching between UIWindows a couple of times, the calls to UnitySendMessage
randomly stop producing any effects, the Unity scene stops updating frames and it even reaches a point where the windows don't change anymore and until the app explodes...
Basically, what I would like to know is:
Is this the best approach to integrate Unity and cocoa views? Is there an 'official' way of doing this? Can anyone point me out an exhaustive tutorial or sample code?
Being this the best approach, any idea on why does it starts failing after a while? Do I need to take any precautions when changing windows? (memory management? Pausing Unity thread?)
Note: I am using Unity Pro, and I have tried both xcode4/ios6 and xcode5/ios7 and the behavior is the same.
Any help would be much appreciated.
For what it's worth, we are just showing an extra UIWindow and hide it when it's no longer necessary, and it just works. Unfortunately, I can't think up of anything special to do to make it work. This does suggest that the problem lay somewhere in the implementation, not the idea. Can't say how to debug it, though... good luck!
Your answer

Follow this Question
Related Questions
Detect state of iOS Mute / Silent Button 2 Answers
Problem with FMOD integration for iOS 0 Answers
How to embed unity ios project with another ios project 0 Answers
iOS integration on PC game 1 Answer