Last Updated on 2021-10-30 by Clay
若是在製作行動裝置的遊戲時,通常我們多半不會設定畫面呈現『橫向』、『縱向』時都可以遊玩 —— 畢竟那對美術設計和關卡設計來說太困難了 ...... 嗯,至少我獨立開發時是絕對辦不到的。
這樣一來,在遊玩時『指定玩家的螢幕只能旋轉為特定的方向』,就是一件很有必要的事情了。
指定方向
Edit > Project Settings > Player > Resolution and Presentation


這裡可以使用 Allowed Orientations for Auto Rotation 指定四個方向,或是直接調整預設的 Default Orientation。
比方說,如果我希望我的螢幕只有橫向(Landscape)的兩種可以旋轉,不支援縱向(Portrait)的畫面,那麼我可以這樣設定:

References
- https://answers.unity.com/questions/1273713/how-to-set-up-unity-for-portrait-mobile-developmen.html
- https://levelup.gitconnected.com/unity-supporting-portrait-and-landscape-screen-orientations-3330fdb0eaec
- https://docs.unity3d.com/ScriptReference/Screen-orientation.html