Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

How to let user change input device on runtime

Discussion in 'Input System' started by BitBenderGames, Jul 22, 2020.

  1. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Hello,

    Using the new input system I would like to show a menu that shows all connected devices (in my case keyboard, mouse & gamepad) and let him exclusively pick one of those. What I have access to is the instance of the InputDevice he selects as well as the PlayerInput component that is attached to the character. How do I go from there? I've been trying varying things with varying degrees of success. I would assume this to be a single line of code (e.g. myPlayerInput.SetDevice(selectedDevice) ), but I don't seem to get it.

    Cheers

    edit: I know how to iterate all devices. I just can't seem to make it bulletproof that the selected device is which controls the player after the user makes his pick.
     
    Last edited: Jul 22, 2020
  2. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Bumping this just once