- Home /
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 ?
Answer by Sam 8 · Apr 27, 2011 at 10:42 PM
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 $$anonymous$$d.
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 SD$$anonymous$$ that makes use of XIBs.
Thanks and have a good one!