Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Input.GetJoystickNames

マニュアルに切り替える
public static string[] GetJoystickNames();

説明

接続されたジョイスティック名の配列を返します

これはユーザー入力の設定画面で役立つものです - これは "Joystick 1" というような名ではなく、実際に使用するジョイスティックの "Logitech WingMan" というような名前を表示することが出来ます。 別のジョイスティックから値を読み取る場合、インプットマネージャーでサポートするジョイスティックの数だけ want to support in the Input Manager.

The position of a joystick in this array corresponds to the joystick number, i.e. the name in position 0 of this array is for the joystick that feeds data into 'Joystick 1' in the Input Manager, the name in position 1 corresponds to 'Joystick 2', and so on. Note that some entries in the array may be blank if no device is connected for that joystick number.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { int i = 0; while (i < 4) { if (Mathf.Abs(Input.GetAxis("Joy" + i + "X")) > 0.2F || Mathf.Abs(Input.GetAxis("Joy" + i + "Y")) > 0.2F) Debug.Log(Input.GetJoystickNames()[i] + " is moved"); i++; } } }