Exemple #1
0
        public static bool GetButton(string name)
        {
            AxisConfiguration axisConfig = GetAxisConfiguration(_instance._currentConfiguration.name, name);

            if (axisConfig == null)
            {
                throw new ArgumentException(string.Format("An button named \'{0}\' does not exist in the active input configuration", name));
            }

            return(axisConfig.GetButton());
        }
Exemple #2
0
        public static bool GetButton(string name)
        {
            AxisConfiguration axisConfig = GetAxisConfiguration(name);

            if (axisConfig == null)
            {
                string error = "The active input configuration doesn't contain a button named " + name;
                throw new ArgumentException(error);
            }

            return(axisConfig.GetButton());
        }
        public static bool GetButton(string name, PlayerID playerID = PlayerID.One)
        {
            AxisConfiguration axisConfig = GetAxisConfiguration(playerID, name);

            if (axisConfig != null)
            {
                return(axisConfig.GetButton());
            }
            else
            {
                Debug.LogError(string.Format("An button named \'{0}\' does not exist in the active input configuration for player {1}", name, playerID));
                return(false);
            }
        }
        private void DisplayAxisConfigurationFields(InputConfiguration inputConfigx, AxisConfiguration axisConfig, Rect screenRect)
        {
            GUIContent gravityInfo = new GUIContent("Gravity", "The speed(in units/sec) at which a digital axis falls towards neutral.");
            GUIContent sensitivityInfo = new GUIContent("Sensitivity", "The speed(in units/sec) at which an axis moves towards the target value.");
            GUIContent snapInfo = new GUIContent("Snap", "If input switches direction, do we snap to neutral and continue from there? For digital axes only.");
            GUIContent deadZoneInfo = new GUIContent("Dead Zone", "Size of analog dead zone. Values within this range map to neutral.");

            GUILayout.BeginArea(screenRect);
            _mainPanelScrollPos = GUILayout.BeginScrollView(_mainPanelScrollPos);
            axisConfig.name = EditorGUILayout.TextField("Name", axisConfig.name);
            axisConfig.description = EditorGUILayout.TextField("Description", axisConfig.description);

            //	Positive Key
            EditorToolbox.KeyCodeField(ref _keyString, ref _editingPositiveKey, "Positive",
                                       "editor_positive_key", axisConfig.positive);
            ProcessKeyString(ref axisConfig.positive, ref _editingPositiveKey);
            //	Negative Key
            EditorToolbox.KeyCodeField(ref _keyString, ref _editingNegativeKey, "Negative",
                                       "editor_negative_key", axisConfig.negative);
            ProcessKeyString(ref axisConfig.negative, ref _editingNegativeKey);
            //	Alt Positive Key
            EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltPositiveKey, "Alt Positive",
                                       "editor_alt_positive_key", axisConfig.altPositive);
            ProcessKeyString(ref axisConfig.altPositive, ref _editingAltPositiveKey);
            //	Alt Negative key
            EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltNegativeKey, "Alt Negative",
                                       "editor_alt_negative_key", axisConfig.altNegative);
            ProcessKeyString(ref axisConfig.altNegative, ref _editingAltNegativeKey);

            axisConfig.gravity = EditorGUILayout.FloatField(gravityInfo, axisConfig.gravity);
            axisConfig.deadZone = EditorGUILayout.FloatField(deadZoneInfo, axisConfig.deadZone);
            axisConfig.sensitivity = EditorGUILayout.FloatField(sensitivityInfo, axisConfig.sensitivity);
            axisConfig.snap = EditorGUILayout.Toggle(snapInfo, axisConfig.snap);
            axisConfig.invert = EditorGUILayout.Toggle("Invert", axisConfig.invert);
            axisConfig.type = (InputType)EditorGUILayout.EnumPopup("Type", axisConfig.type);
            axisConfig.axis = EditorGUILayout.Popup("Axis", axisConfig.axis, _axisOptions);
            axisConfig.joystick = EditorGUILayout.Popup("Joystick", axisConfig.joystick, _joystickOptions);

            if(EditorApplication.isPlaying)
            {
                EditorGUILayout.Space();
                GUI.enabled = false;
                EditorGUILayout.FloatField("Raw Axis", axisConfig.GetAxisRaw());
                EditorGUILayout.FloatField("Axis", axisConfig.GetAxis());
                EditorGUILayout.Toggle("Button", axisConfig.GetButton());
                GUI.enabled = true;
            }

            GUILayout.EndScrollView();
            GUILayout.EndArea();
        }