Hi All,
So, I’m using a UIViewController to manage the OpenGL view created by the default unity AppController class… I need to do it this way given my application setup, and the fact that I need an auto-rotating view which contains both UIKit stuff and the unity view. Anyway, at first I thought that it worked perfectly.
Everything rotates properly, performance is good, etc… but then I noticed I couldn’t interact with the GUI properly… Then I noticed that my FPS view was moving opposite directions according to the opposite rotation…
Note: I’m only using LandscapeLeft and Landscape Right.
Has anyone encountered this and found a fix?
So,
I found a dirty fix where I use a private apple API to flip the coordinates if it’s landscape right… This is pretty awful though and I can’t submit an app with this.
Is there somewhere in Unity3d where I can override the function receiving touches ? Otherwise, I will have to write a big ugly script that acts as a proxy I use for all touches whenever I want touch data… Actually, that won’t work either because the GUI scripts will still use wrong coordinates…
Code I’m using:
@implementation UITouch (Synthesize)
-(void) flipOrientationToLandscapeRight
{
_locationInWindow = CGPointMake(768-_locationInWindow.x, 1024-_locationInWindow.y);
}
@end
and in each similar function found in AppController :
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)
{
for( UITouch* touch in touches){
[touch flipOrientationToLandscapeRight];
}
}
UnitySendTouchesBegin(touches, event);
}
Please help, this is really ugly and I don’t know the inner workings of unity3d well enough to change any internals…