Exemplo n.º 1
0
        private static bool CheckAndAddInput(string axisName, bool isJoystick, int id)
        {
            if (AxisDefined(axisName))
            {
                return(true);
            }
            else
            {
                missingInputs.Add(axisName);

                InputAxis newAxis = new InputAxis();

                newAxis.name        = axisName;
                newAxis.gravity     = isJoystick ? 0f : 1000f;
                newAxis.dead        = isJoystick ? 0.19f : 0.001f;
                newAxis.sensitivity = isJoystick ? 1 : 1000f;
                newAxis.type        = isJoystick ? AxisType.JoystickAxis : AxisType.KeyOrMouseButton;
                if (isJoystick)
                {
                    newAxis.axis = id;
                }
                else
                {
                    newAxis.positiveButton = "joystick button " + id.ToString();
                }

                AddAxis(newAxis);

                return(false);
            }
        }
Exemplo n.º 2
0
        private static void AddAxis(InputAxis axis)
        {
            if (AxisDefined(axis.name))
            {
                return;
            }

            SerializedProperty axesProperty = InputManagerSerializedObject.FindProperty("m_Axes");

            axesProperty.arraySize++;
            InputManagerSerializedObject.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;

            InputManagerSerializedObject.ApplyModifiedProperties();
        }