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;
}

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容