public static InputAction CreateButton(string controlSchemeName, string buttonName, KeyCode primaryKey, KeyCode secondaryKey) { ControlScheme scheme = GetControlScheme(controlSchemeName); if (scheme == null) { Debug.LogError(string.Format("A control scheme named \'{0}\' does not exist", controlSchemeName)); return(null); } if (m_instance.m_actionLookup[controlSchemeName].ContainsKey(buttonName)) { Debug.LogError(string.Format("The control scheme named {0} already contains an action named {1}", controlSchemeName, buttonName)); return(null); } InputAction action = scheme.CreateNewAction(buttonName); InputBinding primary = action.CreateNewBinding(); primary.Type = InputType.Button; primary.Positive = primaryKey; InputBinding secondary = action.CreateNewBinding(primary); secondary.Positive = secondaryKey; action.Initialize(); m_instance.m_actionLookup[controlSchemeName][buttonName] = action; return(action); }
public static InputAction CreateRemoteAxis(string controlSchemeName, string axisName) { ControlScheme scheme = GetControlScheme(controlSchemeName); if (scheme == null) { Debug.LogError(string.Format("A control scheme named \'{0}\' does not exist", controlSchemeName)); return(null); } if (m_instance.m_actionLookup[controlSchemeName].ContainsKey(axisName)) { Debug.LogError(string.Format("The control scheme named {0} already contains an action named {1}", controlSchemeName, axisName)); return(null); } InputAction action = scheme.CreateNewAction(axisName); InputBinding binding = action.CreateNewBinding(); binding.Type = InputType.RemoteAxis; action.Initialize(); m_instance.m_actionLookup[controlSchemeName][axisName] = action; return(action); }
public static InputAction CreateMouseAxis(string controlSchemeName, string axisName, int axis, float sensitivity) { ControlScheme scheme = GetControlScheme(controlSchemeName); if (scheme == null) { Debug.LogError(string.Format("A control scheme named \'{0}\' does not exist", controlSchemeName)); return(null); } if (m_instance.m_actionLookup[controlSchemeName].ContainsKey(axisName)) { Debug.LogError(string.Format("The control scheme named {0} already contains an action named {1}", controlSchemeName, axisName)); return(null); } if (axis < 0 || axis >= InputBinding.MAX_MOUSE_AXES) { Debug.LogError("Mouse axis is out of range. Cannot create new mouse axis."); return(null); } InputAction action = scheme.CreateNewAction(axisName); InputBinding binding = action.CreateNewBinding(); binding.Type = InputType.MouseAxis; binding.Axis = axis; binding.Sensitivity = sensitivity; action.Initialize(); m_instance.m_actionLookup[controlSchemeName][axisName] = action; return(action); }
public static InputAction CreateDigitalAxis(string controlSchemeName, string axisName, KeyCode positive, KeyCode negative, KeyCode altPositive, KeyCode altNegative, float gravity, float sensitivity) { ControlScheme scheme = GetControlScheme(controlSchemeName); if (scheme == null) { Debug.LogError(string.Format("A control scheme named \'{0}\' does not exist", controlSchemeName)); return(null); } if (m_instance.m_actionLookup[controlSchemeName].ContainsKey(axisName)) { Debug.LogError(string.Format("The control scheme named {0} already contains an action named {1}", controlSchemeName, axisName)); return(null); } InputAction action = scheme.CreateNewAction(axisName); InputBinding primary = action.CreateNewBinding(); primary.Type = InputType.DigitalAxis; primary.Positive = positive; primary.Negative = negative; primary.Gravity = gravity; primary.Sensitivity = sensitivity; InputBinding secondary = action.CreateNewBinding(primary); secondary.Positive = altPositive; secondary.Negative = altNegative; action.Initialize(); m_instance.m_actionLookup[controlSchemeName][axisName] = action; return(action); }
public static InputAction CreateAnalogButton(string controlSchemeName, string buttonName, int joystick, int axis) { ControlScheme scheme = GetControlScheme(controlSchemeName); if(scheme == null) { Debug.LogError(string.Format("A control scheme named \'{0}\' does not exist", controlSchemeName)); return null; } if(m_instance.m_actionLookup[controlSchemeName].ContainsKey(buttonName)) { Debug.LogError(string.Format("The input configuration named {0} already contains an action named {1}", controlSchemeName, buttonName)); return null; } if(axis < 0 || axis >= InputBinding.MAX_JOYSTICK_AXES) { Debug.LogError("Joystick axis is out of range. Cannot create new analog button."); return null; } if(joystick < 0 || joystick >= InputBinding.MAX_JOYSTICKS) { Debug.LogError("Joystick is out of range. Cannot create new analog button."); return null; } InputAction action = scheme.CreateNewAction(buttonName); InputBinding binding = action.CreateNewBinding(); binding.Type = InputType.AnalogButton; binding.Joystick = joystick; binding.Axis = axis; action.Initialize(); m_instance.m_actionLookup[controlSchemeName][buttonName] = action; return action; }
public static InputAction CreateAnalogAxis(string controlScheme, string axisName, int joystick, int axis, float sensitivity, float deadZone) { ControlScheme scheme = GetControlScheme(controlScheme); if (scheme == null) { Debug.LogError(string.Format("A control scheme named \'{0}\' does not exist", controlScheme)); return(null); } if (m_instance.m_actionLookup[controlScheme].ContainsKey(axisName)) { Debug.LogError(string.Format("The control scheme named {0} already contains an action named {1}", controlScheme, axisName)); return(null); } if (axis < 0 || axis >= InputBinding.MAX_JOYSTICK_AXES) { Debug.LogError("Joystick axis is out of range. Cannot create new analog axis."); return(null); } if (joystick < 0 || joystick >= InputBinding.MAX_JOYSTICKS) { Debug.LogError("Joystick is out of range. Cannot create new analog axis."); return(null); } InputAction action = scheme.CreateNewAction(axisName); InputBinding binding = action.CreateNewBinding(); binding.Type = InputType.AnalogAxis; binding.Axis = axis; binding.Joystick = joystick; binding.DeadZone = deadZone; binding.Sensitivity = sensitivity; action.Initialize(); m_instance.m_actionLookup[controlScheme][axisName] = action; return(action); }