public void AssignKeyTest() { GameInput.Bind(Controls.SHIP_X_AXIS_POS, KeyCode.W); var key = GameInput.GetBinding(Controls.SHIP_X_AXIS_POS); Assert.AreEqual(KeyCode.W, key); }
public CommandResult Bind(string control, string key) { Controls controlValue = (Controls)Enum.Parse(typeof(Controls), control, true); KeyCode keyValue = (KeyCode)Enum.Parse(typeof(KeyCode), key, true); if (!Enum.IsDefined(typeof(KeyCode), keyValue)) { Debug.LogWarning("Invalid keycode"); return(CommandResult.Failure); } if (!Enum.IsDefined(typeof(Controls), controlValue)) { Debug.LogWarning("Invalid control"); return(CommandResult.Failure); } GameInput.Bind(controlValue, keyValue); return(CommandResult.Success); }
void Start() { GameInput.Bind(Controls.CONSOLE, KeyCode.BackQuote); GameInput.Bind(Controls.SUBMIT, KeyCode.Return); GameInput.Bind(Controls.SHIP_X_AXIS_POS, KeyCode.W); }