Search Unity

Resolved Adding tabs to keyboard navigation; prompting player keypress?

Discussion in 'Input System' started by Selek-of-Vulcan, Aug 13, 2022.

  1. Selek-of-Vulcan

    Selek-of-Vulcan

    Joined:
    Sep 23, 2021
    Posts:
    78
    I'm pretty new to Unity, and I'm very new to the new Input system, but so far I love it. I'm working on a turn-based strategy prototype, mouse-and-keyboard for now. Two questions:

    1. Using the default input system, the keyboard navigation actions let me traverse my menu buttons with up/down arrows and WASD, which is awesome. But I can't figure out how to edit them to add TAB and Shift-TAB as alternative options to navigate. I don't see an option to "edit this navigation setup". Also, maybe TAB and Shift-TAB wouldn't fit, as they are two contols rather than the four of WASD. How would I add them?

    2. The documentation suggested using Keyboard.current.spaceKey.wasPressedThisFrame for getting keypresses. (Actually, the docs are a little out of date; they said space, not spaceKey.) That works great -- I can even call it outside Update(), which I don't think was as easy with the old input system. Using that and a boolean, I can nicely prompt for player keyboard input -- once. But how do I do it successively? E.g., I ask the player a question; get an answer; ask another question; get another answer; etc? Just keep re-using booleans? Use a coroutine? Is there some event I should be listening for or something?

    Many thanks!
     
  2. Selek-of-Vulcan

    Selek-of-Vulcan

    Joined:
    Sep 23, 2021
    Posts:
    78
    I've solved my own question. The default input asset is read-only, so no wonder I couldn't edit it to add Tabs and whatnot! I mean, you *can* sort of edit it, but the Unity editor eventually balks at you, saying the asset couldn't be changed.

    Anyway, I'm now making my own custom input asset. :)