/// <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> /// 軸を追加します。 /// </summary> /// <param name="serializedObject">Serialized object.</param> /// <param name="axis">Axis.</param> public void AddAxis(InputAxis axis) { if (axis.axis < 1) { Debug.LogError("Axisは1以上に設定してください。"); } SerializedProperty axesProperty = serializedObject.FindProperty("m_Axes"); axesProperty.arraySize++; serializedObject.ApplyModifiedProperties(); SerializedProperty axisProperty = axesProperty.GetArrayElementAtIndex(axesProperty.arraySize - 1); GetChildProperty(axisProperty, "m_Name").stringValue = axis.name; GetChildProperty(axisProperty, "descriptiveName").stringValue = axis.descriptiveName; GetChildProperty(axisProperty, "descriptiveNegativeName").stringValue = axis.descriptiveNegativeName; GetChildProperty(axisProperty, "negativeButton").stringValue = axis.negativeButton; GetChildProperty(axisProperty, "positiveButton").stringValue = axis.positiveButton; GetChildProperty(axisProperty, "altNegativeButton").stringValue = axis.altNegativeButton; GetChildProperty(axisProperty, "altPositiveButton").stringValue = axis.altPositiveButton; GetChildProperty(axisProperty, "gravity").floatValue = axis.gravity; GetChildProperty(axisProperty, "dead").floatValue = axis.dead; GetChildProperty(axisProperty, "sensitivity").floatValue = axis.sensitivity; GetChildProperty(axisProperty, "snap").boolValue = axis.snap; GetChildProperty(axisProperty, "invert").boolValue = axis.invert; GetChildProperty(axisProperty, "type").intValue = (int)axis.type; GetChildProperty(axisProperty, "axis").intValue = axis.axis - 1; GetChildProperty(axisProperty, "joyNum").intValue = axis.joyNum; serializedObject.ApplyModifiedProperties(); }
/// <summary> /// マウス用の軸の設定データを作成する /// </summary> /// <returns>The mouse axis.</returns> /// <param name="name">Name.</param> /// <param name="axisNum">Axis number.</param> public static InputAxis CreateMouseAxis(string name, int axisNum) { var axis = new InputAxis(); axis.name = name; axis.sensitivity = 0.1f; axis.type = AxisType.MouseMovement; axis.axis = axisNum; return(axis); }
private static void AddXBOXControllerInputSettingsForMacOSX() { InputManagerGenerator inputManagerGenerator = new InputManagerGenerator(); // LeftStickX { var name = "LeftStickX"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 1)); } // LeftStickY { var name = "LeftStickY"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 2, false, true)); } // RightStickX { var name = "RightStickX"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 3)); } // RightStickY { var name = "RightStickY"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 4)); } // LeftTrigger { var name = "LeftTrigger"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 5)); } // RightTrigger { var name = "RightTrigger"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 6)); } // CrossKeyX { var name = "CrossKeyX"; inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "joystick button 7", "joystick button 8", "", "")); } // CrossKeyY { var name = "CrossKeyY"; inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "joystick button 6", "joystick button 5", "", "")); } }
/// <summary> /// ゲームパッド用の軸の設定データを作成する /// </summary> /// <returns>The joy axis.</returns> /// <param name="name">Name.</param> /// <param name="joystickNum">Joystick number.</param> /// <param name="axisNum">Axis number.</param> public static InputAxis CreatePadAxis(string name, int joystickNum, int axisNum) { var axis = new InputAxis(); axis.name = name; axis.dead = 0.3f; axis.sensitivity = 1; axis.type = AxisType.JoystickAxis; axis.axis = axisNum; axis.joyNum = joystickNum; return(axis); }
/// <summary> /// 押すと1になるキーの設定データを作成する /// </summary> /// <returns>The button.</returns> /// <param name="name">Name.</param> /// <param name="positiveButton">Positive button.</param> /// <param name="altPositiveButton">Alternate positive button.</param> public static InputAxis CreateButton(string name, string positiveButton, string altPositiveButton) { var axis = new InputAxis(); axis.name = name; axis.positiveButton = positiveButton; axis.altPositiveButton = altPositiveButton; axis.gravity = 1000; axis.dead = 0.001f; axis.sensitivity = 1000; axis.type = AxisType.KeyOrMouseButton; return(axis); }
private static void AddXBOXControllerInputSettingsForWindows() { InputManagerGenerator inputManagerGenerator = new InputManagerGenerator(); // LeftStickX { var name = "LeftStickX"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 1)); } // LeftStickY { var name = "LeftStickY"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 2)); } // RightStickX { var name = "RightStickX"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 4)); } // RightStickY { var name = "RightStickY"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 5)); } // CrossKeyX { var name = "CrossKeyX"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 6)); } // CrossKeyY { var name = "CrossKeyY"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 7)); } // L/R Trigger { var name = "L/R Trigger"; inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 3)); } }
private static void AddXBOXControllerInputSettingsForKeyBorad() { InputManagerGenerator inputManagerGenerator = new InputManagerGenerator(); // LeftStickX { var name = "LeftStickX"; inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "a", "d", "", "")); } // LeftStickY { var name = "LeftStickY"; inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "s", "w", "", "")); } // RightStickX { var name = "RightStickX"; inputManagerGenerator.AddAxis(InputAxis.CreateMouseAxis(name, 1)); } // RightStickX { var name = "RightStickX"; inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "left", "right", "", "")); } // RightStickY { var name = "RightStickY"; inputManagerGenerator.AddAxis(InputAxis.CreateMouseAxis(name, 2)); } // RightStickY { var name = "RightStickY"; inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "down", "up", "", "")); } /* * * // LeftTrigger * { * var name = "LeftTrigger"; * inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 5)); * } * * // RightTrigger * { * var name = "RightTrigger"; * inputManagerGenerator.AddAxis(InputAxis.CreatePadAxis(name, 0, 6)); * } * * // CrossKeyX * { * var name = "CrossKeyX"; * inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "joystick button 7", "joystick button 8", "", "")); * } * * // CrossKeyY * { * var name = "CrossKeyY"; * inputManagerGenerator.AddAxis(InputAxis.CreateKeyAxis(name, "joystick button 6", "joystick button 5", "", "")); * } * */ }