public void Users_CanAssignActionAssetToUser() { var asset = ScriptableObject.CreateInstance <InputActionAsset>(); var user = new TestUser(); InputUser.Add(user); Assert.That(user.GetInputActions(), Is.Null); user.AssignInputActions(asset); Assert.That(user.GetInputActions(), Is.SameAs(asset)); }
public void Users_CanAssignActionsToUsers() { var action = new InputAction(); var user = new TestUser(); InputUser.Add(user); Assert.That(user.GetInputActions(), Is.Empty); user.GetInputActions().Push(action); Assert.That(user.GetInputActions(), Is.EquivalentTo(new[] { action })); user.GetInputActions().Clear(); Assert.That(user.GetInputActions(), Is.Empty); }
public void TODO_Users_CanAssignActionsToUsers() { var user = new TestUser(); InputUser.Add(user); var action = new InputAction(); user.GetInputActions().Push(action); Assert.Fail(); }
public void Users_CanAssignActionMapsToUsers() { var map = new InputActionMap(); var action1 = map.AddAction("action1"); var action2 = map.AddAction("action2"); var user = new TestUser(); InputUser.Add(user); user.SetInputActions(map); Assert.That(user.GetInputActions(), Is.EquivalentTo(new[] { action1, action2 })); }
public void Users_CanActivateAndPassivateInput() { var gamepad = InputSystem.AddDevice <Gamepad>(); var action = new InputAction(binding: "<Gamepad>/leftTrigger"); var actionWasTriggered = false; action.performed += _ => actionWasTriggered = true; var user = new TestUser(); InputUser.Add(user); user.GetInputActions().Push(action); // Make sure user is passive by default. Assert.That(user.IsInputActive(), Is.False); InputSystem.QueueStateEvent(gamepad, new GamepadState { leftTrigger = 0.124f }); InputSystem.Update(); Assert.That(actionWasTriggered, Is.False); // Activate user input. user.ActivateInput(); InputSystem.QueueStateEvent(gamepad, new GamepadState { leftTrigger = 0.234f }); InputSystem.Update(); Assert.That(actionWasTriggered, Is.True); actionWasTriggered = false; // Passivate user input again. user.PassivateInput(); InputSystem.QueueStateEvent(gamepad, new GamepadState { leftTrigger = 0.234f }); InputSystem.Update(); Assert.That(actionWasTriggered, Is.False); }