public void Actions_WithMultipleInteractions_DoNotThrowWhenUsingMultipleMaps() { var gamepad = InputSystem.AddDevice <Gamepad>(); var map1 = new InputActionMap("map1"); var map2 = new InputActionMap("map2"); map1.AddAction(name: "action1", type: InputActionType.Button, binding: "<Gamepad>/buttonSouth"); // https://fogbugz.unity3d.com/f/cases/1392559 // Having `press` after `hold` ensures that we have an interaction waiting in performed state and // thus also exercise that path in InputActionState. map2.AddAction(name: "action2", type: InputActionType.Button, binding: "<Gamepad>/buttonNorth", interactions: "hold(duration=0.4),press"); var asset = ScriptableObject.CreateInstance <InputActionAsset>(); asset.AddActionMap(map1); asset.AddActionMap(map2); map2.Enable(); Assert.DoesNotThrow(() => { Press(gamepad.buttonNorth); Release(gamepad.buttonNorth); }); }
private void Initialize() { movement = input.Player; movement.Enable(); movement.GetAction("Jump").performed += ctx => Jump(); movement.GetAction("JumpHold").performed += ctx => JumpHold(); }
public void Init() { m_InputActionMap.Enable(); if (m_CachedWalkStateData != null && m_CachedWalkStateData.Value.walkEnabled) { m_IsPlacementMode = true; } else { m_IsPlacementMode = false; ActivateFlyMode(); } m_IsInit = true; m_InputActionAsset["Place Joystick Action"].Disable(); }
public void Actions_CanRemoveBindingOverridesFromMap_WhenEnabled() { var keyboard = InputSystem.AddDevice <Keyboard>(); var gamepad = InputSystem.AddDevice <Gamepad>(); var map = new InputActionMap(); var action = map.AddAction("action1", binding: "<Keyboard>/enter"); var overrides = new List <InputBinding> { new InputBinding { action = "action1", overridePath = "<Gamepad>/leftTrigger" } }; map.ApplyBindingOverrides(overrides); map.Enable(); Assert.That(action.controls, Is.EquivalentTo(new[] { gamepad.leftTrigger })); map.RemoveBindingOverrides(overrides); Assert.That(action.bindings[0].overridePath, Is.Null); Assert.That(action.controls, Is.EquivalentTo(new[] { keyboard.enterKey })); }
private void Start() { // Store the original pitch of the audio source m_OriginalPitch = m_MovementAudio.pitch; // Unity 2020 New Input System // Get a reference to the MultiplayerEventSystem for this player EventSystem ev = GameObject.Find("EventSystem").GetComponent <EventSystem>(); // Find the Action Map for the Tank actions and enable it InputActionMap playerActionMap = ev.GetComponent <PlayerInput>().actions.FindActionMap("Tank"); playerActionMap.Enable(); // Find the 'Move' action m_MoveAction = playerActionMap.FindAction("MoveTank"); // Find the 'Turn' action m_TurnAction = playerActionMap.FindAction("TurnTank"); // Enable and hook up the events m_MoveAction.Enable(); m_TurnAction.Enable(); m_MoveAction.performed += OnTankMove; m_TurnAction.performed += OnTankTurn; }
public static void setControlScheme(string name) { instance.actionMap = (actionMapNames)Enum.Parse(typeof(actionMapNames), name); if (instance.controls.asset != null) { foreach (InputActionMap actionMap in instance.controls.asset.actionMaps) { actionMap.Disable(); } } InputActionMap input = instance.controls.asset.FindActionMap(name); input.Enable(); axisStates = new List <AxisState>(); axisStates.Add(new AxisState("Dpad")); keyStates = new List <KeyState>(); foreach (InputAction action in input.actions) { string key = action.name; keyStates.Add(new KeyState(key)); action.performed += ctx => { setKeyState(key, true); }; action.canceled += ctx => { setKeyState(key, false); }; } input.FindAction("Movement").started += ctx => { setAxisState("Dpad", ctx.ReadValue <Vector2>()); }; input.FindAction("Movement").performed += ctx => { setAxisState("Dpad", ctx.ReadValue <Vector2>()); }; input.FindAction("Movement").canceled += ctx => { setAxisState("Dpad", ctx.ReadValue <Vector2>()); }; }
void OnEnable() { playerActions.Enable(); inventoryActions.Enable(); attackActions.Enable(); abilityActions.Enable(); }
public void TODO_Users_CanApplySettings_WithInvertedMouseAxes() { var mouse = InputSystem.AddDevice <Mouse>(); var actionMap = new InputActionMap(); var positionAction = actionMap.AddAction("position", binding: "<Mouse>/position"); var deltaAction = actionMap.AddAction("delta", binding: "<Mouse>/delta"); Vector2?receivedPosition = null; Vector2?receivedDelta = null; positionAction.performed += ctx => receivedPosition = ctx.ReadValue <Vector2>(); deltaAction.performed += ctx => receivedDelta = ctx.ReadValue <Vector2>(); var user = InputUser.PerformPairingWithDevice(mouse); user.settings = new InputUserSettings { invertMouseX = true, invertMouseY = true, }; actionMap.Enable(); InputSystem.QueueStateEvent(mouse, new MouseState { position = new Vector2(0.123f, 0.234f), delta = new Vector2(0.345f, 0.456f), }); InputSystem.Update(); //Assert.That(receivedPosition, Is.EqualTo(new Vector2()); Assert.That(receivedDelta, Is.EqualTo(new Vector2(-0.345f, -0.456f)).Using(Vector2EqualityComparer.Instance)); }
public void Initialize() { //reset action events OnJump = null; OnLand = null; OnMove = null; OnStop = null; //resed boolean values _isGrounded = true; _moved = false; _isJumping = false; //reset player input key bindings input = GetComponent <PlayerInputSystem>(); CanMove = true; movement = input.Player; movement.Enable(); movement["Jump"].started += StartJump; movement["Jump"].performed += CancelJump; movement["Jump"].canceled += CancelEarly; if (gameObject.layer.Equals(LayerMask.NameToLayer("Harmony"))) { slideOffOf &= ~LayerMask.NameToLayer("HarmonyGateway"); canJumpOff |= 1 << LayerMask.NameToLayer("Chaos"); } else { slideOffOf &= ~LayerMask.NameToLayer("ChaosGateway"); canJumpOff |= 1 << LayerMask.NameToLayer("Harmony"); } settings = input.Settings; }
private void Awake() { //recup la map InputActionMap playerMap = m_controlsInput.FindActionMap("Player"); //recup les input/action volue InputAction shootAction = playerMap.FindAction("Shoot"); //les deleguate = liste de fonction refenrencer (mettre plein de fonction et on pourra touts les recup) //linker une fonction en une ligne //ctx =nom de ka variable, contexte, contien les info besoin //=> c'est une fleche appeler lambda permet d'ecrire sur une seul ligne shootAction.performed += (ctx) => { Shoot(); }; //autre façon mais moins pratique //shootAction.performed += Shoot; + public void Shoot(InputAction.CallbackContext ctx) {} //move InputAction moveAction = playerMap.FindAction("Move"); moveAction.performed += (ctx) => { m_MovementInput = ctx.ReadValue <Vector2>(); }; //eviter qu'il avance alors qu'on appui pas donc on rement a 0 moveAction.canceled += (ctx) => { m_MovementInput = Vector2.zero; }; //dit quand les input sont activer playerMap.Enable(); }
public void Init() { m_InputActionMap.Enable(); if (m_WalkModeEnableSelector.GetValue()) { m_IsPlacementMode = true; } else { m_IsPlacementMode = false; ActivateFlyMode(); } m_IsInit = true; m_WalkModeTeleportController.SetRotation(Vector3.zero); m_InputActionAsset["Place Joystick Action"].Disable(); }
void Awake() { InputActionMap actionMap = playerControls.FindActionMap("Player"); actionMap.Enable(); look = actionMap.FindAction("Look"); virtualCamera = GetComponent <CinemachineVirtualCamera>(); }
void OnProjectStateDataChanged(UIProjectStateData data) { if (m_ActionMap == null) { m_ActionMap = m_InputActionAsset.FindActionMap("VR", true); } m_ActionMap.Enable(); }
private void InitMovingObject() { _movement["Ability"].Disable(); //_ability.GetAction("Place").performed += _createdInteraction.OnPlaced; _createdInteraction._ability = _ability; _createdInteraction.ReCreated(); _ability.Enable(); }
private void Awake() { // create a new input map in run time debugMap = new InputActionMap("Debug"); fireAction = debugMap.AddAction("Test", binding: "<Keyboard>/m"); // enable map and add relevant key event debugMap.Enable(); fireAction.started += param => UpdateMaterial(); }
void Start() { _player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHandler>(); gameplayMap = actionAsset.FindActionMap("Structures"); _structure = gameObject.GetComponent <Structures>(); gameplayMap.Enable(); _opened = false; clickAction = actionAsset.FindAction("GuiControls"); clickAction.performed += ctx => OnClick(ctx); }
public static void SetActive(this InputActionMap that, bool enable) { if (enable) { that.Enable(); } else { that.Disable(); } }
void Start() { leftMapXR = inputActionAsset.FindActionMap("XRI LeftHand"); rightMapXR = inputActionAsset.FindActionMap("XRI RightHand"); leftMapXR.Enable(); rightMapXR.Enable(); leftButtonXR = leftMapXR.FindAction("Teleport Select"); rightButtonXR = rightMapXR.FindAction("Teleport Select"); }
private static void EnableMap(InputActionMap inputMap) { foreach (var map in Controller.asset.actionMaps) { if (map != inputMap || map != Controller.Debug.Get()) { map.Disable(); } } inputMap.Enable(); }
public static void SetActive(InputActionMap action, bool value) { if (value) { action.Enable(); } else { action.Disable(); } }
private void Awake() { InputActionMap playerMap = m_PlyerControl.FindActionMap("Player"); InputAction rotationCamera = m_PlyerControl.FindAction("Look"); rotationCamera.performed += (ctx) => { m_PosCamera = ctx.ReadValue <Vector2>(); }; rotationCamera.canceled += (ctx) => { m_PosCamera = Vector2.zero; }; dollyDIr = transform.localPosition.normalized; playerMap.Enable(); }
private void OnEnable() { toggleLoggerAction.Enable(); loggerActionMap.Enable(); if (!showInEditor && Application.isEditor) { return; } queue = new Queue <LogMessage>(); Application.logMessageReceived += HandleLog; }
public void Actions_CanPerformPressInteraction_AndTriggerInteractionResetInCallback() { var keyboard = InputSystem.AddDevice <Keyboard>(); var asset = ScriptableObject.CreateInstance <InputActionAsset>(); var map1 = new InputActionMap("map1"); var map2 = new InputActionMap("map2"); asset.AddActionMap(map1); asset.AddActionMap(map2); var action1 = map1.AddAction("action1"); var action2 = map2.AddAction("action2"); // PressInteraction used to set some local state *after* trigger callbacks. This meant that if the // callback triggered a Reset() call, PressInteraction would then overwrite state from the reset. action1.AddBinding("<Keyboard>/a", interactions: "press(behavior=0)"); action2.AddBinding("<Keyboard>/b", interactions: "press(behavior=0)"); action1.performed += _ => { map1.Disable(); map2.Enable(); }; action2.performed += _ => { map2.Disable(); map1.Enable(); }; map1.Enable(); PressAndRelease(keyboard.aKey); Assert.That(map1.enabled, Is.False); Assert.That(map2.enabled, Is.True); PressAndRelease(keyboard.bKey); Assert.That(map1.enabled, Is.True); Assert.That(map2.enabled, Is.False); PressAndRelease(keyboard.aKey); Assert.That(map1.enabled, Is.False); Assert.That(map2.enabled, Is.True); }
public void Open(bool show = true) { _show = show; animator.SetBool(VarShow, show); if (show) { _gameActionMap.Disable(); } else { _gameActionMap.Enable(); } }
public void OpenShop() { rangeGameObject.SetActive(true); otherDrivingActionMap.Disable(); meatSellingActionMap.Enable(); DrivingGameplayManager.Instance.CurrentControllerMode.VirtualCamera.Priority = 0; virtualCamera.Priority++; spawnedMeats = meatsSpawning.SpawnGivenMeats(GameManager.Instance.Player.Inventory.Meats); spawnedEarnedCash = new List <CashBehaviour>(); }
private void Awake() { InputActionMap playerMap = playerControls.FindActionMap("Player"); InputAction shootAction = playerMap.FindAction("Shoot"); shootAction.performed += (ctx) => { Shoot(); }; InputAction moveAction = playerMap.FindAction("Move"); moveAction.performed += (ctx) => { movementInput = ctx.ReadValue <Vector2>(); }; moveAction.canceled += (ctx) => { movementInput = Vector2.zero; }; playerMap.Enable(); }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody>(); count = 0; health = 10; SetCountText(); SetHealthText(); winTextObject.SetActive(false); jumpTextObject.SetActive(false); player.Enable(); Physics.gravity = gravity; }
// Start is called before the first frame update void Start() { Cursor.lockState = CursorLockMode.Locked; onFootMap = actionsAssests.FindActionMap("OnFoot"); onFootMap.Enable(); lookAction = onFootMap.FindAction("look"); lookAction.performed += context => OnLook(context); lookAction.canceled += canx => OnLook(canx); }
public void Devices_CanAutomaticallyActivateActionSetsOnSteamControllers() { var map = new InputActionMap("gameplay"); map.AddAction("fire", binding: "<TestController>/fire"); map.AddAction("look", binding: "<TestController>/look"); m_SteamAPI.AddController(1); InputSystem.Update(); map.Enable(); Assert.That(m_SteamAPI.controllerData[0].actionSetActivations, Is.EquivalentTo(new[] { TestSteamControllerAPI.gameplaySet })); }
void Start() { //Debug.Log("Hello world!"); playerInput = GetComponent <PlayerInput>(); playerRigidbody = GetComponent <Rigidbody>(); animationUpdate = GetComponent <PlayerAnimation>(); cabinActionMap = playerInput.actions.FindActionMap("Cabin"); pilotActionMap = playerInput.actions.FindActionMap("Pilot"); gunnerActionMap = playerInput.actions.FindActionMap("Gunner"); combatActionMap = playerInput.actions.FindActionMap("Combat"); cabinActionMap.Enable(); mode = PlayerMode.CabinMode; }