在工作中经常需要集成一些第三方的SDK,也出了挺多问题并解决,在这里记录一下解决办法。
问题一:集成的第三方SDK不能跟随Unity3D的打包参数锁定旋转方向
将UnityAPPController.mm中的
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
// No rootViewController setted because we are switching from one view controller to another, all orientations should enabled
if ([window rootViewController] == nil)
return UIInterfaceOrientationMaskAll;
// Some presentation controllers (e.g. UIImagePickerController) require portrait orientation and will throw exception if not supported.
// At the same time enabling all orientations by returning UIInterfaceOrientationMaskAll might cause unwanted orientation change
// (e.g. when using UIActivityViewController to "share to" another application, iOS will use supportedInterfaceOrientations to possibly reorient).
// So to avoid exception we are returning combination of constraints for root view controller and orientation requested by iOS.
// _forceInterfaceOrientationMask updated in willChangeStatusBarOrientation, which called if some presentation controller insists on orientation change.
return [[window rootViewController] supportedInterfaceOrientations] | _forceInterfaceOrientationMask;
}
supportedInterfaceOrientationsForWindow这个方法整段屏蔽或删除 原因:Unity在允许自由旋转屏幕的时候会自动生成这个方法,即使你已经选定了锁定的旋转方向,这个方法还是会将游戏以外的(如SDK的)界面忽略在锁定之外,造成游戏旋转方向正确,但SDK旋转方向不正确的问题
Unity集成第三方SDK问题总结
https://xn--wgv44dw7s.cn/2018/07/11/KWTkFFoX
评论