Ejemplo n.º 1
0
        public UnityInputAxes createAxis(string name, string positiveControlName, string negativeControlName, AutoGamepadConstants.UNITY_PLAYER_NUMBER player, AutoGamepadConstants.ITEM_TYPE type, AutoGamepadConstants.UNITY_AXIS_TYPE unityType, AutoGamepadConstants.UNITY_AXIS_NUMBER axisNumber, bool invert)
        {
            UnityInputAxes inputAxis = new UnityInputAxes();

            inputAxis.name = name;


            if (!positiveControlName.Equals(""))
            {
                if (positiveControlName.Equals("escape"))
                {
                    inputAxis.positiveButton = "escape";
                }
                else
                {
                    inputAxis.positiveButton = fetchControllerPrefix(player) + positiveControlName;
                }
            }
            if (!negativeControlName.Equals(""))
            {
                if (negativeControlName.Equals("escape"))
                {
                    inputAxis.negativeButton = "escape";
                }
                else
                {
                    inputAxis.negativeButton = fetchControllerPrefix(player) + negativeControlName;
                }
            }

            if (type == AutoGamepadConstants.ITEM_TYPE.Digital)
            {
                inputAxis.sensitivity = (AutoGamepadGenerator.overrideCollection[name].sensitivity == 0f) ? 1000f : AutoGamepadGenerator.overrideCollection[name].sensitivity;
                inputAxis.gravity     = (AutoGamepadGenerator.overrideCollection[name].gravity == 0f) ? 1000f : AutoGamepadGenerator.overrideCollection[name].gravity;
                inputAxis.dead        = (AutoGamepadGenerator.overrideCollection[name].dead == 0f) ? .001f : AutoGamepadGenerator.overrideCollection[name].dead;
            }
            else
            {
                inputAxis.sensitivity = (AutoGamepadGenerator.overrideCollection[name].sensitivity == 0f) ? 1f : AutoGamepadGenerator.overrideCollection[name].sensitivity;
                inputAxis.gravity     = (AutoGamepadGenerator.overrideCollection[name].gravity == 0f) ? 0f : AutoGamepadGenerator.overrideCollection[name].gravity;
                inputAxis.dead        = (AutoGamepadGenerator.overrideCollection[name].dead == 0f) ? .19f : AutoGamepadGenerator.overrideCollection[name].dead;
            }

            inputAxis.snap            = (AutoGamepadGenerator.overrideCollection[name].snap == false) ? false : true;
            inputAxis.invert          = (AutoGamepadGenerator.overrideCollection[name].invert == false) ? invert : !invert;
            inputAxis.type            = unityType;
            inputAxis.axis            = axisNumber;
            inputAxis.joyNum          = player;
            inputAxis.descriptiveName = AutoGamepadConstants.GENERATED;



            return(inputAxis);
        }
Ejemplo n.º 2
0
        //this function is responsible for reading and populating a dictionary collection that corresponds to
        //the current InputManager file
        public static SortedList <string, UnityInputAxes> ReadAxisAsset()
        {
            SortedList <string, UnityInputAxes> fileCollection = new SortedList <string, UnityInputAxes>();
            UnityInputAxes currentObject;

            //read the file
            SerializedObject   serializedObject = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0]);
            SerializedProperty axesProperty     = serializedObject.FindProperty("m_Axes");

            int count = axesProperty.arraySize;

            for (int i = 0; i < count; i++)
            {
                currentObject = new UnityInputAxes();
                SerializedProperty childElement = axesProperty.GetArrayElementAtIndex(i);

                currentObject.inputAssetIndex         = i;
                currentObject.name                    = GetChildProperty(childElement, "m_Name").stringValue;
                currentObject.descriptiveName         = GetChildProperty(childElement, "descriptiveName").stringValue;
                currentObject.descriptiveNegativeName = GetChildProperty(childElement, "descriptiveNegativeName").stringValue;
                currentObject.negativeButton          = GetChildProperty(childElement, "negativeButton").stringValue;
                currentObject.positiveButton          = GetChildProperty(childElement, "positiveButton").stringValue;
                currentObject.altNegativeButton       = GetChildProperty(childElement, "altNegativeButton").stringValue;
                currentObject.altPositiveButton       = GetChildProperty(childElement, "altPositiveButton").stringValue;
                currentObject.gravity                 = GetChildProperty(childElement, "gravity").floatValue;
                currentObject.dead                    = GetChildProperty(childElement, "dead").floatValue;
                currentObject.sensitivity             = GetChildProperty(childElement, "sensitivity").floatValue;
                currentObject.snap                    = GetChildProperty(childElement, "snap").boolValue;
                currentObject.invert                  = GetChildProperty(childElement, "invert").boolValue;
                currentObject.type                    = (AutoGamepadConstants.UNITY_AXIS_TYPE)GetChildProperty(childElement, "type").intValue;
                currentObject.axis                    = (AutoGamepadConstants.UNITY_AXIS_NUMBER)GetChildProperty(childElement, "axis").intValue;
                currentObject.joyNum                  = (AutoGamepadConstants.UNITY_PLAYER_NUMBER)GetChildProperty(childElement, "joyNum").intValue;

                fileCollection.Add(currentObject.name + "__" + currentObject.inputAssetIndex.ToString(), currentObject);
            }

            return(fileCollection);
        }
Ejemplo n.º 3
0
        //this function is responsible for displaying a single UnityInputAxis object
        public static void DisplayInputAxis(UnityInputAxes inputAxis, UnityInputAxes overideAxis)
        {
            GUIStyle oneIndent = new GUIStyle(GUI.skin.label);

            oneIndent.margin    = new RectOffset(20, 0, 0, 0);
            oneIndent.fontStyle = FontStyle.Bold;

            GUIStyle twoIndent = new GUIStyle(GUI.skin.label);

            twoIndent.margin = new RectOffset(40, 0, 0, 0);


            GUILayout.Label("InputManager Index: " + inputAxis.inputAssetIndex.ToString(), oneIndent);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Positive Descriptive Name: " + inputAxis.descriptiveName, twoIndent, GUILayout.Width(400f));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Negative Descriptive Name: " + inputAxis.descriptiveNegativeName, twoIndent, GUILayout.Width(400f));
            GUILayout.EndHorizontal();

            GUILayout.Label("Positive Button: " + inputAxis.positiveButton, twoIndent);
            GUILayout.Label("Negative Button: " + inputAxis.negativeButton, twoIndent);
            GUILayout.Label("Alternative Positive Button: " + inputAxis.altPositiveButton, twoIndent);
            GUILayout.Label("Alternative Negative Button: " + inputAxis.altNegativeButton, twoIndent);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Gravity: " + inputAxis.gravity.ToString(), twoIndent, GUILayout.Width(400f));
            if (overideAxis != null)
            {
                GUILayout.Label("Gravity Overide: ", GUILayout.Width(180f));
                overideAxis.gravity = EditorGUILayout.FloatField(overideAxis.gravity);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Dead Zone: " + inputAxis.dead.ToString(), twoIndent, GUILayout.Width(400f));
            if (overideAxis != null)
            {
                GUILayout.Label("Dead Zone Overide: ", GUILayout.Width(180f));
                overideAxis.dead = EditorGUILayout.FloatField(overideAxis.dead);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Sensitivity: " + inputAxis.sensitivity.ToString(), twoIndent, GUILayout.Width(400f));
            if (overideAxis != null)
            {
                GUILayout.Label("Sensitivity Overide: ", GUILayout.Width(180f));
                overideAxis.sensitivity = EditorGUILayout.FloatField(overideAxis.sensitivity);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Snap: " + inputAxis.snap.ToString(), twoIndent, GUILayout.Width(400f));
            if (overideAxis != null)
            {
                GUILayout.Label("Snap Overide: ", GUILayout.Width(180f));
                overideAxis.snap = EditorGUILayout.Toggle(overideAxis.snap);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Invert: " + inputAxis.invert.ToString(), twoIndent, GUILayout.Width(400f));
            if (overideAxis != null)
            {
                GUILayout.Label("Invert Overide: ", GUILayout.Width(180f));
                overideAxis.invert = EditorGUILayout.Toggle(overideAxis.invert);
            }
            GUILayout.EndHorizontal();

            GUILayout.Label("Type: " + inputAxis.type.ToString(), twoIndent);
            GUILayout.Label("Axis: " + inputAxis.axis.ToString(), twoIndent);
            GUILayout.Label("Joystick Number: " + inputAxis.joyNum.ToString(), twoIndent);
        }