iOS整合高通AR (Vuforia+Unity) 横屏时图像颠倒的问题

整合的部分参见其他文章 iOS中Unity横屏

有个问题一直没有解决,就是使用AR功能时,图像有时候会颠倒,最近意外解决了
横屏的方式仍然相同,主工程保持Portrait不变
在具体显示Unity的页面,添加横屏代码

  override var shouldAutorotate: Bool{
        return false
    }
    
    override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation{
        return .landscapeRight
    }

在UnityAppController.mm中
注释以下三行代码

- (void)applicationWillResignActive:(UIApplication*)application
{
   ::printf("-> applicationWillResignActive()\n");

   if(_unityAppReady)
   {
       UnitySetPlayerFocus(0);

       _wasPausedExternal = UnityIsPaused();
       if (_wasPausedExternal == false)
       {
           // do pause unity only if we dont need special background processing
           // otherwise batched player loop can be called to run user scripts
           int bgBehavior = UnityGetAppBackgroundBehavior();
           if(bgBehavior == appbgSuspend || bgBehavior == appbgExit)
           {
               // Force player to do one more frame, so scripts get a chance to render custom screen for minimized app in task manager.
               // NB: UnityWillPause will schedule OnApplicationPause message, which will be sent normally inside repaint (unity player loop)
               // NB: We will actually pause after the loop (when calling UnityPause).
               UnityWillPause();
               [self repaint];
               UnityPause(1);

//                _snapshotView = [self createSnapshotView];
//                if(_snapshotView)
//                    [_rootView addSubview:_snapshotView];
           }
       }
   }

   _didResignActive = true;
}

就可以了,但支持向右横屏,向左横屏,图像一直是颠倒的。

你可能感兴趣的:(iOS整合高通AR (Vuforia+Unity) 横屏时图像颠倒的问题)