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. Dismiss Notice

Question Help map a button event using New Input System.

Discussion in 'UI Toolkit' started by VentaGames, Jul 21, 2023.

  1. VentaGames

    VentaGames

    Joined:
    Jul 9, 2021
    Posts:
    122
    Hi there,
    I just switched to UIToolKit, so -
    previously, I had forward/backward buttons (canvas), and On-Screen Button component, where I mapped Control Path to 'W', 'S' keys. (Move)
    So, i'm reading these movements in like this:
    Code (CSharp):
    1. var move = _inputs.Player.Move.ReadValue<Vector2>();
    Now, I can't add On-Screen Button component to my buttons in UIToolKit, i think i need to pass something somewhere, i can catch mybutton.clicked { ... } in the code, but how to send this event to the input system?

    Thanks in advance.
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    I think you're thinking backwards here. If you've set up UI to 'read' inputs, then just send those inputs to whatever system is waiting for said inputs. I don't think you need to worry about going through the input system here.
     
  3. VentaGames

    VentaGames

    Joined:
    Jul 9, 2021
    Posts:
    122
    I also start to think, that i'll need some InputManager class that will collect all inputs (from the Input systems, UI, etc...) and combine them all in one.
     
    spiney199 likes this.