Warning: Declaration of action_plugin_linebreak::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/linebreak/action.php on line 41

Warning: Declaration of action_plugin_markdownextra::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/markdownextra/action.php on line 16

Warning: Declaration of action_plugin_syntaxhighlighter3_action::register(Doku_Event_Handler &$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/syntaxhighlighter3/action/action.php on line 28
015 ユーザー入力を受け取る [stepism@UE4メモ]

ユーザ用ツール

サイト用ツール


wiki:unity:tips:015

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

次のリビジョン
前のリビジョン
wiki:unity:tips:015 [2014/11/14 03:25]
127.0.0.1 外部編集
— (現在)
ライン 1: ライン 1:
-====== 015 ユーザー入力を受け取る ====== 
- 
-===== 概要 ===== 
-Inputクラスを使って、ユーザーの入力情報を受け取ります。 
- 
-==== キーが押されたか? ==== 
-<code csharp> 
-if (Input.GetKeyDown("​a"​)) 
-{ 
- Debug.Log("​a!"​);​ 
-} 
-if (Input.GetButtonDown("​Jump"​)) 
-{ 
- Debug.Log("​Jump!"​);​ 
-} 
-if (Input.GetKeyDown("​up"​)) 
-{ 
- Debug.Log("​up!"​);​ 
-} 
-</​code>​ 
- 
- 
-==== キーが押されたか? ==== 
-<code csharp> 
-if (Input.GetKeyUp("​b"​)) 
-{ 
- Debug.Log("​b!"​);​ 
-} 
-if (Input.GetButtonUp("​Fire1"​)) 
-{ 
- Debug.Log("​Fire1!"​);​ 
-} 
-</​code>​ 
- 
-==== キーを押し続けているか? ==== 
-<code csharp> 
-if (Input.GetKey("​c"​)) 
-{ 
- Debug.Log("​c!"​);​ 
-} 
-if (Input.GetButton("​Fire2"​)) 
-{ 
- Debug.Log("​Fire2!"​);​ 
-} 
-</​code>​ 
- 
-==== 水平方向の入力量(-1.0fから1.0f) ==== 
-<code csharp> 
-float horizontal = Input.GetAxis("​Horizontal"​);​ 
-</​code>​ 
- 
-==== 垂直方向の入力量(-1.0fから1.0f) ====  
-<code csharp> 
-float vertical = Input.GetAxis("​Vertical"​); ​ 
-</​code>​ 
-  
-  
-==== マウス入力 ====  
-<code csharp> 
-if (Input.GetMouseButtonDown(0)) 
-{ 
- Debug.Log("​Left Click!"​);​ //​ 左クリック。 
-} 
-if (Input.GetMouseButtonDown(1)) 
-{ 
- Debug.Log("​Right Click!"​);​ //​ 右クリック。 
-} 
-if (Input.GetMouseButtonDown(2)) 
-{ 
- Debug.Log("​Center Click!"​);​ //​ 中央クリック。 
-} 
-</​code>​ 
-GetMouseButtonDown( 0 ) はシングルタッチと同等です。 
- 
-==== マウスの座標を取得 ==== 
-<code csharp> 
-Vector2 mousePos = Input.mousePosition;​ 
-</​code>​ 
- 
-==== マウスホイールの移動量を取得 ==== 
-<code csharp> 
-float wheel = Input.GetAxis("​Mouse ScrollWheel"​);​ 
-</​code>​ 
- 
-==== タッチ入力 ==== 
-<code csharp> 
-for( int i = 0; i < Input.touchCount;​ i++ ) 
-{ 
- Touch touch = Input.GetTouch(i);​ 
- Vector2 pos = touch.position;​ 
-  
- switch( touch.phase ) 
- { 
- case Began: 
- print( "touch Began!"​ ); // タッチ開始。 
- break; 
-  
- case Moved: 
- print( "touch Moved!"​ ); // タッチしていて移動中。 
- break; 
-  
- case Stationary: 
- print( "touch Stationary!"​ ); // タッチしているが移動していない。 
- break; 
-  
- case Ended: 
- print( "touch Ended!"​ ); // タッチ終了(離した)。 
- break; 
-  
- case Canceled:​ //​ システムによってキャンセルした。 
- print( "touch Canceled!"​ ); 
- break; 
- }; 
-} 
-</​code>​ 
- 
-==== 加速度センサーの値 ==== 
-<code csharp> 
-Vector3 lowPassValue = Input.acceleration;​ 
-</​code>​ 
- 
-==== ジャイロセンサー有効 ==== 
-<code csharp> 
-Input.gyro.enabled = true; 
-</​code>​ 
- 
-==== キーバインドの確認 ==== 
-Jumpなどキーの割り当てはEdit -> Project Settings -> Input で確認できます。 
-{{:​wiki:​unity:​tips:​unity_input_keybind.png?​300|}} 
- 
- 
-[[http://​ws.cis.sojo-u.ac.jp/​~izumi/​Unity_Documentation_jp/​Documentation/​Manual/​Input.html|Unity - Input]] 
- 
- 
  
wiki/unity/tips/015.1415935522.txt.gz · 最終更新: 2015/01/06 14:13 (外部編集)