Unity + iOS , unityとiOSの連動法

2013年2月15日

Objective C : How to show a custom UIView on top of Unity
Original Link

http://answers.unity3d.com/questions/32848/objectivec-how-to-show-a-custom-uiview-on-top-of-u.html

Here’s the code for showing and hiding the view:

– (void) showCustomView
{
UnitySetAudioSessionActive(true);
UnityPause(true);

self._customUIViewController = [[UIViewController alloc] autorelease];
[[self getTopApplicationWindow] addSubview:self._customUIViewController.view];

if(self._customUIViewController != nil)
{
FAWController *fawView = [[FAWController alloc] initWithAPIKey:@”d0d” delegate:self]; //some custom initialization
[self._customUIViewController presentModalViewController:fawView animated:YES];
[fawView release];
}
}

-(void)hideCustomView {

if(self._customUIViewController != nil)
{
[self._customUIViewController dismissModalViewControllerAnimated:YES];
}
[self._customUIViewController.view removeFromSuperview];

self._customUIViewController = nil;

UnityPause(false);
UnitySetAudioSessionActive(true);
}
//helper function
– (UIWindow*) getTopApplicationWindow
{
UIApplication* clientApp = [UIApplication sharedApplication];
NSArray* windows = [clientApp windows];
UIWindow* topWindow = nil;

if (windows && [windows count] > 0)
topWindow = [[clientApp windows] objectAtIndex:0];

return topWindow;
}
The View shows just fine, and it dismisses nicely when I close it, but then Unity doesn’t receive any more input (as if something invisible is still being displayed on top).

Answer : on the -(void)hideCustomView function set dismissModalViewControllerAnimated property to NO instead of YES, it works fine. Unity receives input fine
==================================================================================================================================================================

Unity plugin to handle loading native Cocoa UI’s with ease
Original link:

http://forum.unity3d.com/threads/56755-Unity-plugin-to-handle-loading-native-Cocoa-UI-s-with-ease

Have your say