コード例 #1
0
        /// <summary>
        /// 軸を追加します。
        /// </summary>
        /// <param name="serializedObject">Serialized object.</param>
        /// <param name="data">Axis.</param>
        void AddAxis(InputSettingData data)
        {
            // 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                  = data.name;
            GetChildProperty(axisProperty, "descriptiveName").stringValue         = data.descriptive;
            GetChildProperty(axisProperty, "descriptiveNegativeName").stringValue = data.negativeDescriptive;
            GetChildProperty(axisProperty, "negativeButton").stringValue          = data.negativeButton;
            GetChildProperty(axisProperty, "positiveButton").stringValue          = data.positiveButton;
            GetChildProperty(axisProperty, "altNegativeButton").stringValue       = data.altNegativeButton;
            GetChildProperty(axisProperty, "altPositiveButton").stringValue       = data.altPositiveButton;
            GetChildProperty(axisProperty, "gravity").floatValue                  = data.gravity;
            GetChildProperty(axisProperty, "dead").floatValue        = data.dead;
            GetChildProperty(axisProperty, "sensitivity").floatValue = data.sensitivity;
            GetChildProperty(axisProperty, "snap").boolValue         = data.snap;
            GetChildProperty(axisProperty, "invert").boolValue       = data.invert;
            GetChildProperty(axisProperty, "type").intValue          = (int)data.inputType;
            GetChildProperty(axisProperty, "axis").intValue          = (int)data.axisType;
            GetChildProperty(axisProperty, "joyNum").intValue        = (int)data.joystickNum;

            serializedObject.ApplyModifiedProperties();
        }
コード例 #2
0
        /// <summary>
        /// ゲームパッド用の軸の設定データを作成する
        /// </summary>
        /// <returns>The joy axis.</returns>
        /// <param name="name">Name.</param>
        /// <param name="joystickNum">Joystick number.</param>
        /// <param name="axisType">Axis number.</param>
        public static InputSettingData CreatePadAxis(string name, JoystickNum joystickNum, AxisType axisType)
        {
            var axis = new InputSettingData(name);

            axis.name        = name;
            axis.dead        = 0.2f;
            axis.sensitivity = 1;
            axis.inputType   = InputType.JoystickAxis;
            axis.axisType    = axisType;
            axis.joystickNum = joystickNum;

            return(axis);
        }
コード例 #3
0
        public void SetInputSettingData(List <InputSettingData> dataList)
        {
            if (dataList == null)
            {
                return;
            }

            Clear();
            for (int iInput = 0; iInput < dataList.Count; iInput++)
            {
                InputSettingData data = dataList[iInput];
                AddAxis(data);
            }
        }
コード例 #4
0
        /// <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 InputSettingData CreateButton(string name, string positiveButton, string altPositiveButton)
        {
            var axis = new InputSettingData(name);

            axis.name              = name;
            axis.positiveButton    = positiveButton;
            axis.altPositiveButton = altPositiveButton;
            axis.gravity           = 1000;
            axis.dead              = 0.001f;
            axis.sensitivity       = 1000;
            axis.inputType         = InputType.KeyOrMouseButton;

            return(axis);
        }
コード例 #5
0
        InputSettingData GetInputSettingData(SerializedProperty property)
        {
            InputSettingData data = new InputSettingData(GetChildProperty(property, "m_Name").stringValue, false);

            data.descriptive         = GetChildProperty(property, "descriptiveName").stringValue;
            data.negativeDescriptive = GetChildProperty(property, "descriptiveNegativeName").stringValue;
            data.negativeButton      = GetChildProperty(property, "negativeButton").stringValue;
            data.positiveButton      = GetChildProperty(property, "positiveButton").stringValue;
            data.altNegativeButton   = GetChildProperty(property, "altNegativeButton").stringValue;
            data.altPositiveButton   = GetChildProperty(property, "altPositiveButton").stringValue;
            data.gravity             = GetChildProperty(property, "gravity").floatValue;
            data.dead        = GetChildProperty(property, "dead").floatValue;
            data.sensitivity = GetChildProperty(property, "sensitivity").floatValue;
            data.snap        = GetChildProperty(property, "snap").boolValue;
            data.invert      = GetChildProperty(property, "invert").boolValue;
            data.inputType   = (InputType)GetChildProperty(property, "type").intValue;
            data.axisType    = (AxisType)GetChildProperty(property, "axis").intValue;
            data.joystickNum = (JoystickNum)GetChildProperty(property, "joyNum").intValue;
            return(data);
        }
コード例 #6
0
        static void AddMyXBoxControllerDefinition()
        {
            Debug.Log("hello");
            InputManagerAccessor accessor = new InputManagerAccessor();

            _inputSettingList = accessor.GetInputSettingDataList();

            //Aボタン
            {
                var data =
                    new InputSettingData(nameof(XBoxButtons.XboxA))
                {
                    joystickNum    = (int)JoystickNum.All,
                    inputType      = InputType.KeyOrMouseButton,
                    positiveButton = "joystick button 0"
                };
                _inputSettingList.Add(data);
            }
            //Bボタン
            {
                var data =
                    new InputSettingData(nameof(XBoxButtons.XboxB))
                {
                    joystickNum    = (int)JoystickNum.All,
                    inputType      = InputType.KeyOrMouseButton,
                    positiveButton = "joystick button 1"
                };
                _inputSettingList.Add(data);
            }

            //Xボタン
            {
                var data =
                    new InputSettingData(nameof(XBoxButtons.XboxX))
                {
                    joystickNum    = (int)JoystickNum.All,
                    inputType      = InputType.KeyOrMouseButton,
                    positiveButton = "joystick button 2"
                };
                _inputSettingList.Add(data);
            }

            //Yボタン
            {
                var data =
                    new InputSettingData(nameof(XBoxButtons.XboxY))
                {
                    joystickNum    = (int)JoystickNum.All,
                    inputType      = InputType.KeyOrMouseButton,
                    positiveButton = "joystick button 3"
                };
                _inputSettingList.Add(data);
            }

            //Lボタン
            {
                var data =
                    new InputSettingData(nameof(XBoxButtons.XboxL))
                {
                    joystickNum    = (int)JoystickNum.All,
                    inputType      = InputType.KeyOrMouseButton,
                    positiveButton = "joystick button 4"
                };
                _inputSettingList.Add(data);
            }

            //Rボタン
            {
                var data =
                    new InputSettingData(nameof(XBoxButtons.XboxR))
                {
                    joystickNum    = (int)JoystickNum.All,
                    inputType      = InputType.KeyOrMouseButton,
                    positiveButton = "joystick button 5"
                };
                _inputSettingList.Add(data);
            }

            //Backボタン
            {
                var data =
                    new InputSettingData(nameof(XBoxButtons.XBoxBack))
                {
                    joystickNum    = (int)JoystickNum.All,
                    inputType      = InputType.KeyOrMouseButton,
                    positiveButton = "joystick button 6"
                };
                _inputSettingList.Add(data);
            }

            //Startボタン
            {
                var data =
                    new InputSettingData(nameof(XBoxButtons.XBoxStart))
                {
                    joystickNum    = (int)JoystickNum.All,
                    inputType      = InputType.KeyOrMouseButton,
                    positiveButton = "joystick button 7"
                };
                _inputSettingList.Add(data);
            }

            //左スティック押し込み
            {
                var data =
                    new InputSettingData(nameof(XBoxButtons.XBoxLeftStickClick))
                {
                    joystickNum    = (int)JoystickNum.All,
                    inputType      = InputType.KeyOrMouseButton,
                    positiveButton = "joystick button 8"
                };
                _inputSettingList.Add(data);
            }

            //右スティック押し込み
            {
                var data =
                    new InputSettingData(nameof(XBoxButtons.XBoxRightStickClick))
                {
                    joystickNum    = (int)JoystickNum.All,
                    inputType      = InputType.KeyOrMouseButton,
                    positiveButton = "joystick button 9"
                };
                _inputSettingList.Add(data);
            }


            //スティック入力
            //左スティックX軸
            {
                var data =
                    new InputSettingData(nameof(XBoxAxis.XboxLeftStickX))
                {
                    joystickNum = (int)JoystickNum.All,
                    inputType   = InputType.JoystickAxis,
                    axisType    = AxisType.XAxis,
                    dead        = 0.001f,
                    gravity     = 3f,
                    sensitivity = 3f
                };
                _inputSettingList.Add(data);
            }

            //スティック入力
            //左スティックY軸
            {
                var data =
                    new InputSettingData(nameof(XBoxAxis.XboxLeftStickY))
                {
                    joystickNum = (int)JoystickNum.All,
                    inputType   = InputType.JoystickAxis,
                    axisType    = AxisType.YAxis,
                    invert      = true,
                    dead        = 0.001f,
                    gravity     = 3f,
                    sensitivity = 3f
                };
                _inputSettingList.Add(data);
            }


            //スティック入力
            //右スティックX軸
            {
                var data =
                    new InputSettingData(nameof(XBoxAxis.XboxRightStickX))
                {
                    joystickNum = (int)JoystickNum.All,
                    inputType   = InputType.JoystickAxis,
                    axisType    = AxisType._4thAxis,
                    dead        = 0.001f,
                    gravity     = 3f,
                    sensitivity = 3f
                };
                _inputSettingList.Add(data);
            }

            //スティック入力
            //右スティックY軸
            {
                var data =
                    new InputSettingData(nameof(XBoxAxis.XboxRightStickY))
                {
                    joystickNum = (int)JoystickNum.All,
                    inputType   = InputType.JoystickAxis,
                    axisType    = AxisType._5thAxis,
                    invert      = true,
                    dead        = 0.001f,
                    gravity     = 3f,
                    sensitivity = 3f
                };
                _inputSettingList.Add(data);
            }

            //左トリガー,0から1の値
            {
                var data =
                    new InputSettingData(nameof(XBoxAxis.XBoxLeftTrigger))
                {
                    joystickNum = (int)JoystickNum.All,
                    inputType   = InputType.JoystickAxis,
                    axisType    = AxisType._9thAxis,
                    dead        = 0.001f,
                    gravity     = 3f,
                    sensitivity = 3f
                };
                _inputSettingList.Add(data);
            }

            //右トリガー,0から1の値
            {
                var data =
                    new InputSettingData(nameof(XBoxAxis.XBoxRightTrigger))
                {
                    joystickNum = (int)JoystickNum.All,
                    inputType   = InputType.JoystickAxis,
                    axisType    = AxisType._10thAxis,
                    dead        = 0.001f,
                    gravity     = 3f,
                    sensitivity = 3f
                };
                _inputSettingList.Add(data);
            }


            accessor.SetInputSettingData(_inputSettingList);
        }