包含1節(jié)視頻教程
相信喜歡尤娜的朋友是相當(dāng)多的!我們一起學(xué)習(xí)臨摹技術(shù),讓你從細(xì)節(jié)到整體都畫的有模有樣!繪畫其實(shí)就是這么簡單。
![]()
|
![]() unity3D引擎教程 下面小編將以一個例子向各位盆友們介紹Unity3D 屏幕的哪些事兒。 強(qiáng)制屏幕四個方向不旋轉(zhuǎn)的方法 [代碼]c#/cpp/oc代碼: 1void Start () { 2 //縱向 上下 兩個方向 3 iPhoneKeyboard.autorotateToPortrait = false; 4 iPhoneKeyboard.autorotateToPortraitUpsideDown = false; 5 6 //橫向 上下兩個方向 7 iPhoneKeyboard.autorotateToLandscapeLeft = false; 8 iPhoneKeyboard.autorotateToLandscapeRight = false; 9} 自動旋轉(zhuǎn)屏幕的方法,此方式適用于Unity3.3及一下的版本。 Input.deviceOrientation 可以得到當(dāng)前IOS 設(shè)備屏幕的方向狀態(tài)。 Screen.orientation 設(shè)置屏幕的反轉(zhuǎn)情況 [代碼]c#/cpp/oc代碼: 01void Update () { 02 //處理橫向兩個方向旋轉(zhuǎn) 03 if(Input.deviceOrientation == DeviceOrientation.LandscapeLeft) 04 { 05 if (Screen.orientation != ScreenOrientation.LandscapeLeft) { 06 Screen.orientation = ScreenOrientation.LandscapeLeft; 07 } 08 }else if(Input.deviceOrientation == DeviceOrientation.LandscapeRight) 09 { 10 if (Screen.orientation != ScreenOrientation.LandscapeRight) { 11 Screen.orientation = ScreenOrientation.LandscapeRight; 12 } 13 14 }else 15 //處理縱向兩個方向的旋轉(zhuǎn) 16 if(Input.deviceOrientation == DeviceOrientation.Portrait) 17 { 18 if (Screen.orientation != ScreenOrientation.Portrait) { 19 Screen.orientation = ScreenOrientation.Portrait; 20 } 21 }else if(Input.deviceOrientation == DeviceOrientation.PortraitUpsideDown) 22 { 23 if (Screen.orientation != ScreenOrientation.PortraitUpsideDown) { 24 Screen.orientation = ScreenOrientation.PortraitUpsideDown; 25 } 26 } 27 } 3.4及以上的版本可以在Setting for IOS 設(shè)置中直接設(shè)置屏幕旋轉(zhuǎn)。 下面的游戲例子,通過左邊的按鈕直接切換屏幕旋轉(zhuǎn)狀態(tài),右邊的按鈕打開iPhone輸入狀態(tài)框。 [代碼]c#/cpp/oc代碼: 01using UnityEngine; 02using System.Collections; 03 04public class Main : MonoBehaviour { 05 06 //鍵盤輸入 07 private iPhoneKeyboard keyboard; 08 09 //字體皮膚 10 public GUISkin fontSkin; 11 12 // Use this for initialization 13 void Start () { 14 } 15 16 // Update is called once per frame 17 void Update () { 18 } 19 20 21 void OnGUI() { 22 //設(shè)置皮膚 23 GUI.skin = fontSkin; 24 25 //強(qiáng)制屏幕縱向 26 if (GUI.Button(new Rect(10, 10, 300, 100), "change LandscapeLeft")) { 27 Screen.orientation = ScreenOrientation.LandscapeLeft; 28 }else if (GUI.Button(new Rect(10, 110, 300, 100), "change LandscapeRight")) { 29 Screen.orientation = ScreenOrientation.LandscapeRight; 30 }else 31 32 //強(qiáng)制屏幕橫向 33 if (GUI.Button(new Rect(10, 210, 300, 100), "change Portrait")) { 34 Screen.orientation = ScreenOrientation.Portrait; 源自: Unity3D引擎:感應(yīng)iOS設(shè)備旋轉(zhuǎn)與iPhone鍵盤事件 http://bbs.9ria.com/forum.php?mod=viewthread&tid=435068&extra= http://www.cgwwo.com/thread-27120-1-1.html
贊0 踩0 |
未知用戶
2005-2025 朱峰社區(qū) 版權(quán)所有 遼ICP備2021001865號-1
2005-2025 ZhuFeng Community All Rights Reserved
VIP