public override void OnInspectorGUI() { base.OnInspectorGUI(); InputManager manager = target as InputManager; if (GUILayout.Button("反映")) { generator = new InputManagerGenerator(); generator.Clear(); var inputList = manager.GetInputSettingList(); for (int i = 0; i < inputList.Length; i++) { var data = inputList[i]; generator.AddAxis(InputAxis.CreateKeyAxis(data.name, data.negative, data.positive, data.altNegative, data.altPositive)); if (data.isJoyPadAxisCreate) { generator.AddAxis(InputAxis.CreatePadAxis(data.name, data.joyStickNum, data.axisNum)); } } Debug.Log("反映成功"); } }
public static void EnableSteeringContoller() { InputManagerGenerator inputManagerGenerator = new InputManagerGenerator(); // 現在の設定をクリア inputManagerGenerator.Clear(); // ハンドル入力を登録 { var name = "HANDLE"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 1)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "a", "d", "left", "right")); } // ボタン入力を登録 foreach (var button in buttons) { var buttonName = button.Key; var inputName = button.Value; inputManagerGenerator.AddAxis(InputAxis.CreateButton(buttonName, inputName, inputName)); } // デフォルト { inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis("Horizontal", 0, 1)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis("Horizontal", "a", "d", "left", "right")); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis("Vertical", 0, 2)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis("Vertical", "s", "w", "down", "up")); inputManagerGenerator.AddAxis(InputAxis.CreateButton("Submit", "enter", "joystick button 0")); inputManagerGenerator.AddAxis(InputAxis.CreateButton("Cancel", "escape", "joystick button 1")); } // 完了 Debug.Log("ProjectSetting/InputにSteeringControllerを設定しました。"); }
/// <summary> /// グローバルな入力設定を追加する(OK、キャンセルなど) /// </summary> /// <param name="inputManagerGenerator">Input manager generator.</param> private static void AddGlobalInputSettings(InputManagerGenerator inputManagerGenerator) { // 横方向 { var name = "Horizontal"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 1)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "a", "d", "left", "right")); } // 縦方向 { var name = "Vertical"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 2)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "s", "w", "down", "up")); } // 決定 { var name = "OK"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, "z", "joystick button 0")); } // キャンセル { var name = "Cancel"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, "x", "joystick button 1")); } // ポーズ { var name = "Pause"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, "escape", "joystick button 7")); } }
/// <summary> /// プレイヤーごとの入力設定を追加する /// </summary> /// <param name="inputManagerGenerator">Input manager generator.</param> /// <param name="playerIndex">Player index.</param> private static void AddPlayerInputSettings(InputManagerGenerator inputManagerGenerator, int playerIndex) { if (playerIndex < 0 || playerIndex > 3) { Debug.LogError("プレイヤーインデックスの値が不正です。"); } string upKey = "", downKey = "", leftKey = "", rightKey = "", attackKey = ""; GetAxisKey(out upKey, out downKey, out leftKey, out rightKey, out attackKey, playerIndex); int joystickNum = playerIndex + 1; // 横方向 { var name = string.Format("Player{0} Horizontal", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 1)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } // 縦方向 { var name = string.Format("Player{0} Vertical", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 2)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } // 攻撃 { var axis = new InputAxis(); var name = string.Format("Player{0} Attack", playerIndex); var button = string.Format("joystick {0} button 0", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, attackKey)); } }
/// <summary> /// グローバルな入力設定を追加する(OK、キャンセルなど) /// </summary> /// <param name="inputManagerGenerator">Input manager generator.</param> private static void AddGlobalInputSettings(InputManagerGenerator inputManagerGenerator) { // 横方向 { var name = "Horizontal"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 1)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "a", "d", "left", "right")); } // 縦方向 { var name = "Vertical"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 2)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "s", "w", "down", "up")); } }
/// <summary> /// プレイヤーごとの入力設定を追加する /// </summary> /// <param name="inputManagerGenerator">Input manager generator.</param> /// <param name="playerIndex">Player index.</param> private static void AddPlayerInputSettings(InputManagerGenerator inputManagerGenerator, int playerIndex) { if (playerIndex < 0 || playerIndex > 3) { Debug.LogError("プレイヤーインデックスの値が不正です。"); } string upKey = "", downKey = "", leftKey = "", rightKey = ""; List <string> fireKeys; GetAxisKey(out upKey, out downKey, out leftKey, out rightKey, out fireKeys, playerIndex); int joystickNum = playerIndex + 1; Debug.Log("プレイヤー" + joystickNum + "の設定を追加します。"); // 横方向 { var name = string.Format("P{0}Horizontal", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 1)); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 5)); //5thAxis inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } // 縦方向 { var name = string.Format("P{0}Vertical", playerIndex); //Yはinvert設定しないとギャクに成る inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 2, true)); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 6, true)); //6thAxis inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } // 攻撃 for (int i = 0; i < FIRENUM; i++) { var axis = new InputAxis(); var name = string.Format("P{0}Fire{1}", playerIndex, i + 1); var button = string.Format("joystick {0} button {1}", joystickNum, i); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, fireKeys[i])); } }
/// <summary> /// プレイヤーごとの入力設定を追加する /// </summary> /// <param name="inputManagerGenerator">Input manager generator.</param> /// <param name="playerIndex">Player index.</param> /// private static void AddPlayerInputSettings(InputManagerGenerator inputManagerGenerator, int playerIndex) { if (playerIndex < 0 || playerIndex > 3) { Debug.LogError("プレイヤーインデックスの値が不正です。"); } string upKey = "", downKey = "", leftKey = "", rightKey = "", attackKey = ""; GetAxisKey(out upKey, out downKey, out leftKey, out rightKey, out attackKey, playerIndex); List <string> buttonCodeList = Enum.GetNames(typeof(UdonObservable.InputRx.GamePad.GamePadObservable.ButtonCode)).ToList(); int joystickNum = playerIndex + 1; // 横方向 { var name = string.Format("Player{0} Horizontal", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 1)); // inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } // 縦方向 { var name = string.Format("Player{0} Vertical", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 2)); // inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } // 全てのキーの生成 { foreach (var key in buttonCodeList.Select((value, index) => new { value, index })) { var name = string.Format("Player{0} {1}", joystickNum, key.value); var button = string.Format("joystick {0} button {1}", joystickNum, key.index); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, attackKey)); } } }
/** ******************************************************************************** * @summary プレイヤーごとの入力設定を追加する ***********************************************************************************/ private static void AddPlayerInputSettings(InputManagerGenerator inputManagerGenerator, int playerIndex) { if (playerIndex < 0 || playerIndex > 3) { Debug.LogError("プレイヤーインデックスの値が不正です。"); } string upKey = "", downKey = "", leftKey = "", rightKey = "", jumpKey = "", characterKey = "", eraserKey = "", chalkKey = "", changeStateKey = "", actionKey = ""; GetAxisKey(out upKey, out downKey, out leftKey, out rightKey, out jumpKey, out characterKey, out eraserKey, out chalkKey, out changeStateKey, out actionKey, playerIndex); int joystickNum = playerIndex + 1; // 横方向 { var name = string.Format("Player{0} Horizontal", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 1)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } // 縦方向 { var name = string.Format("Player{0} Vertical", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 2)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } // チョーク /* * { * var axis = new InputAxis(); * var name = string.Format("Player{0} Chalk", playerIndex); * var button = string.Format("joystick {0} button 0", joystickNum); * inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, chalkKey)); * } */ // 黒板消し { var name = string.Format("Player{0} Eraser", playerIndex); var button = string.Format("joystick {0} button 4", joystickNum); // 4: L1 inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, eraserKey)); } // キャラクター /* * { * var axis = new InputAxis(); * var name = string.Format("Player{0} Character", playerIndex); * var button = string.Format("joystick {0} button 3", joystickNum); * inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, characterKey)); * } */ // ステート切り替え { var name = string.Format("Player{0} ChangeState", playerIndex); var button = string.Format("joystick {0} button 5", joystickNum); // 5: R1 inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, changeStateKey)); } // アクション { var name = string.Format("Player{0} Action", playerIndex); var button = string.Format("joystick {0} button 0", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, actionKey)); } // ジャンプ { var name = string.Format("Player{0} Jump", playerIndex); var button = string.Format("joystick {0} button 2", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, jumpKey)); } }
/// <summary> /// プレイヤーごとの入力設定を追加する /// </summary> /// <param name="inputManagerGenerator">Input manager generator.</param> /// <param name="playerIndex">Player index.</param> private static void AddPlayerInputSettings(InputManagerGenerator inputManagerGenerator, int playerIndex, string controllerName) { if (playerIndex < 0 || playerIndex > 3) { Debug.LogError("プレイヤーインデックスの値が不正です。"); } string upKey = "", downKey = "", leftKey = "", rightKey = "", attackKey1 = "", attackKey2 = "", attackKey3 = ""; GetAxisKey(out upKey, out downKey, out leftKey, out rightKey, out attackKey1, out attackKey2, out attackKey3, playerIndex); int joystickNum = playerIndex + 1; //ここに各コントローラーの設定を作成 #region BSGPAC02 Series if (controllerName == "BSGPAC02 Series") { //スティック //横方向 { var name = string.Format("Player{0}_Horizontal", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, controllerName, joystickNum, 1)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } //縦方向 { var name = string.Format("Player{0}_Vertical", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, controllerName, joystickNum, 2)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } //攻撃ボタン //弱 { var name = string.Format("Player{0}_Attack1", playerIndex); var button = string.Format("joystick {0} button 0", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey1)); } //中 { var name = string.Format("Player{0}_Attack2", playerIndex); var button = string.Format("joystick {0} button 1", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey2)); } //強 { var name = string.Format("Player{0}_Attack3", playerIndex); var button = string.Format("joystick {0} button 2", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey3)); } //決定キーなどの設定 { //決定 { var name = "OK"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "z", "joystick button 1")); } //キャンセル { var name = "Cancel"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "x", "joystick button 2")); } //ポーズ { var name = "Pause"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "escape", "joystick button 8")); } } } #endregion #region RAP.N3 else if (controllerName == "RAP.N3") { //スティック //横方向 { var name = string.Format("Player{0}_Horizontal", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, controllerName, joystickNum, 1)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } //縦方向 { var name = string.Format("Player{0}_Vertical", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, controllerName, joystickNum, 2)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } //攻撃ボタン //弱 { //var axis = new InputAxis(); var name = string.Format("Player{0}_Attack1", playerIndex); var button = string.Format("joystick {0} button 1", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey1)); } //中 { var name = string.Format("Player{0}_Attack2", playerIndex); var button = string.Format("joystick {0} button 2", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey2)); } //強 { var name = string.Format("Player{0}_Attack3", playerIndex); var button = string.Format("joystick {0} button 7", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey3)); } //決定キーなどの設定 { //決定 { var name = "OK"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "z", "joystick button 0")); } //キャンセル { var name = "Cancel"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "x", "joystick button 1")); } //ポーズ { var name = "Pause"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "escape", "joystick button 8")); } } } #endregion #region Logicool Dual Action else if (controllerName == "Logicool Dual Action") { //スティック //横方向 { var name = string.Format("Player{0}_Horizontal", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, controllerName, joystickNum, 1)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } //縦方向 { var name = string.Format("Player{0}_Vertical", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, controllerName, joystickNum, 2)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } //攻撃ボタン //弱 { var name = string.Format("Player{0}_Attack1", playerIndex); var button = string.Format("joystick {0} button 0", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey1)); } // 中 { var name = string.Format("Player{0}_Attack2", playerIndex); var button = string.Format("joystick {0} button 1", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey2)); } //強 { var name = string.Format("Player{0}_Attack3", playerIndex); var button = string.Format("joystick {0} button 2", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey3)); } //決定キーなどの設定 { //決定 { var name = "OK"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "z", "joystick button 1")); } //キャンセル { var name = "Cancel"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "x", "joystick button0")); } //ポーズ { var name = "Pause"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "escape", "joystick button 7")); } } } #endregion #region Controller (Gamepad F310) else if (controllerName == "Controller (Gamepad F310)") { //スティック //横方向 { var name = string.Format("Player{0}_Horizontal", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, controllerName, joystickNum, 1)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } //縦方向 { var name = string.Format("Player{0}_Vertical", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, controllerName, joystickNum, 2)); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } //攻撃ボタン //弱 { var name = string.Format("Player{0}_Attack1", playerIndex); var button = string.Format("joystick {0} button 0", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey1)); } //中 { var name = string.Format("Player{0}_Attack2", playerIndex); var button = string.Format("joystick {0} button 1", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey2)); } //強 { var name = string.Format("Player{0}_Attack3", playerIndex); var button = string.Format("joystick {0} button 2", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, button, attackKey3)); } //決定キーなどの設定 { //決定 { var name = "OK"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "z", "joystick button 1")); } //キャンセル { var name = "Cancel"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "x", "joystick button0")); } //ポーズ { var name = "Pause"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "escape", "joystick button 7")); } } } #endregion //キーボードのみ設定 else { #region キーボードのみ //スティック //横方向 { var name = string.Format("Player{0}_Horizontal", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } //縦方向 { var name = string.Format("Player{0}_Vertical", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } //攻撃ボタン //弱 { //var axis = new InputAxis(); var name = string.Format("Player{0}_Attack1", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "", attackKey1)); } //中 { var name = string.Format("Player{0}_Attack2", playerIndex); var button = string.Format("joystick {0} button 1", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "", attackKey2)); } //強 { var name = string.Format("Player{0}_Attack3", playerIndex); var button = string.Format("joystick {0} button 2", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "", attackKey3)); } //決定キーなどの設定 { //決定 { var name = "OK"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "z", "")); } //キャンセル { var name = "Cancel"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "x", "")); } //ポーズ { var name = "Pause"; inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, controllerName, "escape", "")); } } #endregion Debug.Log("***player" + playerIndex + " -> " + controllerName + " の入力が設定されていません キーボードのみ設定します***"); } }
/// <summary> /// グローバルな入力設定を追加する(OK、キャンセルなど) /// </summary> /// <param name="inputSettingGenerator">Input manager generator.</param> private static void AddGlobalInputSettings(InputSettingGenerator inputSettingGenerator) { // LX { var name = "Player0_LX"; inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 1)); inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "a", "d", "left", "right")); } // LY { var name = "Player0_LY"; inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 2)); inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "s", "w", "down", "up")); } // RX { var name = "Player0_RX"; inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 4)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_1", 0, 3)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_none", 0, 28)); inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "a", "d", "left", "right")); } // RY { var name = "Player0_RY"; inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 5)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_1", 0, 4)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_none", 0, 28)); inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "s", "w", "down", "up")); } // DX { var name = "Player0_DX"; inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 6)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_1", 0, 5)); inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "a", "d", "left", "right")); } // DY { var name = "Player0_DY"; inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 7)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_1", 0, 6)); inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "s", "w", "down", "up")); } // ボタン // 0 { var name = "Player0_Btn0"; inputSettingGenerator.AddAxis(InputAxis.CreateButton(name, "z", 0, "joystick button 0")); } // 1 { var name = "Player0_Btn1"; inputSettingGenerator.AddAxis(InputAxis.CreateButton(name, "x", 0, "joystick button 1")); } // 2 { var name = "Player0_Btn2"; inputSettingGenerator.AddAxis(InputAxis.CreateButton(name, "a", 0, "joystick button 2")); } // 3 { var name = "Player0_Btn3"; inputSettingGenerator.AddAxis(InputAxis.CreateButton(name, "s", 0, "joystick button 3")); } // 4 { var name = "Player0_Btn4"; inputSettingGenerator.AddAxis(InputAxis.CreateButton(name, "q", 0, "joystick button 4")); } // 5 { var name = "Player0_Btn5"; inputSettingGenerator.AddAxis(InputAxis.CreateButton(name, "w", 0, "joystick button 5")); } // 6 { var name = "Player0_Btn6"; inputSettingGenerator.AddAxis(InputAxis.CreateButton(name, "c", 0, "joystick button 6")); } // 7 { var name = "Player0_Btn7"; inputSettingGenerator.AddAxis(InputAxis.CreateButton(name, "v", 0, "joystick button 7")); } }
/// <summary> /// プレイヤーごとの入力設定を追加する /// </summary> /// <param name="inputSettingGenerator">Input manager generator.</param> /// <param name="playerIndex">Player index.</param> private static void AddPlayerInputSettings(InputSettingGenerator inputSettingGenerator, int playerIndex) { if (playerIndex < 0 || playerIndex > 3) { Debug.LogError("プレイヤーインデックスの値が不正です。"); } string upKey = "", downKey = "", leftKey = "", rightKey = "", attackKey = ""; GetAxisKey(out upKey, out downKey, out leftKey, out rightKey, out attackKey, playerIndex); int joystickNum = playerIndex + 1; // LX { var name = string.Format("Player{0}_LX", playerIndex); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 1)); //inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } // LY { var name = string.Format("Player{0}_LY", playerIndex); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 2)); //inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } // RX { var name = string.Format("Player{0}_RX", playerIndex); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 4)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_1", joystickNum, 3)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_none", joystickNum, 28)); //inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } // RY { var name = string.Format("Player{0}_RY", playerIndex); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 5)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_1", joystickNum, 4)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_none", joystickNum, 28)); //inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } // DX { var name = string.Format("Player{0}_DX", playerIndex); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 6)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_1", joystickNum, 5)); //inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } // DY { var name = string.Format("Player{0}_DY", playerIndex); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 7)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_1", joystickNum, 6)); //inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } // button for (int i = 0; i < 16; i++) { //var axis = new InputAxis(); var name = string.Format("Player{0}_Btn" + i, playerIndex); var button = string.Format("joystick {0} button " + i, joystickNum); inputSettingGenerator.AddAxis(InputAxis.CreateButton(name, button, joystickNum, attackKey)); } // LT/RT { var name = string.Format("Player{0}_LRTrigger", playerIndex); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 3)); inputSettingGenerator.AddAxis(InputAxis.CreatePadAxis(name + "_none", joystickNum, 28)); //inputSettingGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } }
/// <summary> /// プレイヤーごとの入力設定を追加する /// </summary> /// <param name="inputManagerGenerator">Input manager generator.</param> /// <param name="playerIndex">Player index.</param> private static void AddPlayerInputSettings(InputManagerGenerator inputManagerGenerator, int playerIndex) { if (playerIndex < 1 || playerIndex > 4) { Debug.LogError("プレイヤーインデックスの値が不正です。"); } string upKey = "", downKey = "", leftKey = "", rightKey = "", attackKey = ""; GetAxisKey(out upKey, out downKey, out leftKey, out rightKey, out attackKey, playerIndex); int joystickNum = playerIndex; // 横方向 { var name = string.Format("Player{0} Horizontal", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 1)); //inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } // 縦方向 { var name = string.Format("Player{0} Vertical", playerIndex); var padAxis = InputAxis.CreatePadAxis(name, joystickNum, 2); padAxis.invert = true; inputManagerGenerator.AddAxis(padAxis); //inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } // 横方向 { var name = string.Format("Player{0} Horizontal2", playerIndex); inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, joystickNum, 4)); //inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, leftKey, rightKey, "", "")); } // 縦方向 { var name = string.Format("Player{0} Vertical2", playerIndex); var padAxis = InputAxis.CreatePadAxis(name, joystickNum, 5); padAxis.invert = true; inputManagerGenerator.AddAxis(padAxis); //inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, downKey, upKey, "", "")); } // 攻撃 //{ // var axis = new InputAxis(); // var name = string.Format("Player{0} Attack", playerIndex); // var button = string.Format("joystick {0} button 1", joystickNum); // inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, attackKey)); //} // Cancel { var axis = new InputAxis(); var name = string.Format("Player{0} Cancel", playerIndex); var button = string.Format("joystick {0} button 2", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, attackKey)); } // Item { var axis = new InputAxis(); var name = string.Format("Player{0} Item", playerIndex); var button = string.Format("joystick {0} button 3", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, attackKey)); } // Throw { var axis = new InputAxis(); var name = string.Format("Player{0} Throw", playerIndex); var button = string.Format("joystick {0} button 0", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, attackKey)); } //Hold { var axis = new InputAxis(); var name = string.Format("Player{0} Hold", playerIndex); var button = string.Format("joystick {0} button 1", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, attackKey)); } // Dash { var axis = new InputAxis(); var name = string.Format("Player{0} Dash", playerIndex); var button = string.Format("joystick {0} button 5", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, attackKey)); } // Pause 難市 { var axis = new InputAxis(); var name = string.Format("Player{0} Pause", playerIndex); var button = string.Format("joystick {0} button 7", joystickNum); inputManagerGenerator.AddAxis(InputAxis.CreateButton(name, button, attackKey)); } }