Ejemplo n.º 1
0
            private static void AddAxis(InputManagerAxis axis)
            {
                if (isAxisDefined(axis.name))
                {
                    return;
                }


                SerializedObject   serializedObject = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0]);
                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();
            }
Ejemplo n.º 2
0
        private void AddAxis(InputManagerAxis axis)
        {
            SerializedProperty axesProperty = inputManagerAsset.FindProperty("m_Axes");

            // Creates a new axis by incrementing the size of the m_Axes array.
            axesProperty.arraySize++;

            // Get the new axis be querying for the last array element.
            SerializedProperty axisProperty = axesProperty.GetArrayElementAtIndex(axesProperty.arraySize - 1);

            // Iterate through all the properties of the new axis.
            while (axisProperty.Next(true))
            {
                switch (axisProperty.name)
                {
                case "m_Name":
                    axisProperty.stringValue = axis.Name;
                    break;

                case "descriptiveName":
                    axisProperty.stringValue = axis.DescriptiveName;
                    break;

                case "descriptiveNegativeName":
                    axisProperty.stringValue = axis.DescriptiveNegativeName;
                    break;

                case "negativeButton":
                    axisProperty.stringValue = axis.NegativeButton;
                    break;

                case "positiveButton":
                    axisProperty.stringValue = axis.PositiveButton;
                    break;

                case "altNegativeButton":
                    axisProperty.stringValue = axis.AltNegativeButton;
                    break;

                case "altPositiveButton":
                    axisProperty.stringValue = axis.AltPositiveButton;
                    break;

                case "gravity":
                    axisProperty.floatValue = axis.Gravity;
                    break;

                case "dead":
                    axisProperty.floatValue = axis.Dead;
                    break;

                case "sensitivity":
                    axisProperty.floatValue = axis.Sensitivity;
                    break;

                case "snap":
                    axisProperty.boolValue = axis.Snap;
                    break;

                case "invert":
                    axisProperty.boolValue = axis.Invert;
                    break;

                case "type":
                    axisProperty.intValue = (int)axis.Type;
                    break;

                case "axis":
                    axisProperty.intValue = axis.Axis - 1;
                    break;

                case "joyNum":
                    axisProperty.intValue = axis.JoyNum;
                    break;
                }
            }
        }