iLMS知識社群歷程檔登入
位置: 黃國哲 > Unity
1090623 螢幕翻轉設定方式
by 黃國哲 2020-06-23 08:26:23, 回應(0), 人氣(596)

螢幕自動翻轉 參考BLOG




語法:

// 初始狀態, 該狀態可以自由翻轉螢幕, 
// 它雖然效果跟 AutoRotation 相同, 
// 但值卻不一樣, 所以想要自由翻轉的話, 還是使用 AutoRotation 吧! 
Screen.orientation = ScreenOrientation.Unknown;
 
 
// 螢幕翻轉為 正向, 話筒在上, 且不能翻轉
Screen.orientation = ScreenOrientation.Portrait;
 
 
// 螢幕翻轉為 倒向, 話筒在下, 且不能翻轉
Screen.orientation = ScreenOrientation.PortraitUpsideDown;
 
 
// 螢幕翻轉為 向左倒, 話筒在左, 且不能翻轉, 
// 這邊 Landscape 與 LandscapeLeft 意思是一樣的, 
// 就連值也相同, 所以兩個都可以使用. 
Screen.orientation = ScreenOrientation.Landscape;
Screen.orientation = ScreenOrientation.LandscapeLeft;
 
 
// 螢幕翻轉為 向右倒, 話筒在右, 且不能翻轉
Screen.orientation = ScreenOrientation.LandscapeRight;
 
 
// 可自由翻轉, 但可以設定方向的限制
Screen.orientation = ScreenOrientation.AutoRotation;
 
// 設定是否可以 向左倒
Screen.autorotateToLandscapeLeft = true;
 
// 設定是否可以 向右倒
Screen.autorotateToLandscapeRight = true;
 
// 設定是否可以 正向
Screen.autorotateToPortrait = true;
 
// 設定是否可以 倒向
Screen.autorotateToPortraitUpsideDown = true;
 
回應