iOS view blocking input from unity

Hi, I am developing a plugin that uses iOS to show ads in our unity app but whenever i present a ViewController Unity's Input stops working. Is there a way to pass input from a UIViewController to unity's Input ?

this script works but it doesn't allow the ball to move around the screen, the errors i was before hand are gone but now no movement is eligible

1 Answer

1

Unity's AppController makes an EAGLView and adds it as the first subview of the keyWindow. This view is what usually gets the input but when you put another subview in the keyWindow input is first send to that.

So in order to pass the input along to the original EAGLView you need to override these functions in your UIViewController: touchesBegan touchesEnded touchesCancelled touchesMoved.

- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
    [[[[[UIApplication sharedApplication] keyWindow] subviews] objectAtIndex:0] touchesBegan:touches withEvent:event];
}
- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
    [[[[[UIApplication sharedApplication] keyWindow] subviews] objectAtIndex:0] touchesEnded:touches withEvent:event];
}
- (void) touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event
{
    [[[[[UIApplication sharedApplication] keyWindow] subviews] objectAtIndex:0] touchesCancelled:touches withEvent:event];
}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
    [[[[[UIApplication sharedApplication] keyWindow] subviews] objectAtIndex:0] touchesMoved:touches withEvent:event];
}

Hey, Sam. Small favor/question, if you don't mind. I'm starting to research the way Unity handles iOS views; that led me to this question. Could you refer me to whatever resource taught you best how it all works? Like the OP, I'm making an SDK that makes use of XIBs. Thanks and have a good one!

Please use comments to comment and answers to answers. Also you should probably actually post the code.