iOS整合高通AR (Vuforia+Unity) 橫屏?xí)r圖像顛倒的問題

整合的部分參見其他文章 iOS中Unity橫屏

有個(gè)問題一直沒有解決,就是使用AR功能時(shí),圖像有時(shí)候會(huì)顛倒,最近意外解決了
橫屏的方式仍然相同,主工程保持Portrait不變
在具體顯示Unity的頁(yè)面,添加橫屏代碼

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

就可以了,但支持向右橫屏,向左橫屏,圖像一直是顛倒的。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容