朱峰社區(qū)首頁 朱峰社區(qū)

搜索資源 注冊|登陸

等待

返回 展開菜單
按功能 按軟件

尤娜的繪畫

尤娜的繪畫

包含1節(jié)視頻教程

相信喜歡尤娜的朋友是相當(dāng)多的!我們一起學(xué)習(xí)臨摹技術(shù),讓你從細(xì)節(jié)到整體都畫的有模有樣!繪畫其實(shí)就是這么簡單。

關(guān)閉

unity3D引擎教程:iphone鍵盤

關(guān)注:1337 留言:0 樓主:877088934@qq.com 發(fā)帖時間:15年9月11日

877088934@qq.com

普通會員

877088934@qq.com

社區(qū)摯友:3級

關(guān)注3807人

  • 積分

    61

  • 登陸

    4

  • 發(fā)帖

    52

間隔線

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

朱峰社區(qū)微信公眾號

回頂部

1.復(fù)制文本發(fā)給您的QQ好友或群、微信等;好友點(diǎn)擊鏈接以后,轉(zhuǎn)發(fā)就成功了。 2.如朋友點(diǎn)擊您的鏈接,您需要需刷新一下才行;同一個好友僅能點(diǎn)擊一次。
購買VIP,觀看所有收費(fèi)教程!!