1. 程式人生 > >Orientation Auto Rotation旋轉螢幕crash問題(Unity3D開發之十四)

Orientation Auto Rotation旋轉螢幕crash問題(Unity3D開發之十四)

猴子原創,歡迎轉載。轉載請註明: 轉載自Cocos2Der-CSDN,謝謝!

今天執行一個場景時候,welcome場景可以旋轉,進入主場景後發現只要旋轉手機螢幕就會crash。

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'UnityDefaultViewController should be used 
only if unity is set to autorotate'

出錯資訊已經顯示是使用auto rotation導致的。

Unity Build setting裡面已經是Auto Rotation,為何主場景無法旋轉?

而且錯誤表示:是我在呼叫autorotate,但是我設定的模式卻不是autorotate。

最後全域性搜尋了下,果然有測試程式碼手工設定了螢幕方向為Left。修改為自動後,問題解決。

Screen.orientation = ScreenOrientation.AutoRotation;

問題雖然是個小問題,但是想起了那誰誰前天線上遊戲由於開發寫的測試程式碼跑到線上,導致玩家多了一個裝了很多道具的寶箱。

所以,誰要是說:”這個功能先這樣就好了, 等正式配置出來了,我在修改。“,我保證不掐死你…