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

How to show bindings in button text?

Discussion in 'Input System' started by canberk07, Nov 22, 2019.

  1. canberk07

    canberk07

    Joined:
    Jun 12, 2019
    Posts:
    12
    Hello everyone,

    I was looking for a way to read binding paths in script so I can show them as string in a button text (later I will try to make it controls rebinding menu). Sorry if what I say doesn't make sense, .I am a beginner in game development still trying to learn lots of things. I looked through the documentation for new input system but couldn't quite understand :) Thanks.
     
  2. joeconstable97

    joeconstable97

    Joined:
    Jul 30, 2013
    Posts:
    49
    I too am looking for a way to do this.
     
  3. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Stay tuned. We should have an improvement here shortly. Many users have struggled with this and rather than trying to explain at length how to do this with the current API and how to avoid the many pitfalls, I figured it's a hole that better be plugged now by just providing a simple wrapper API that requires little explanation.
     
    canberk07 and joeconstable97 like this.
  4. robinfischerinnogames

    robinfischerinnogames

    Joined:
    Apr 7, 2017
    Posts:
    9
    canberk07 likes this.
  5. canberk07

    canberk07

    Joined:
    Jun 12, 2019
    Posts:
    12

    Thank you.
     
  6. tobias_froihofer

    tobias_froihofer

    Joined:
    Jul 30, 2015
    Posts:
    45
    I have created an asset (available in the asset store) which provides button prefabs for easy rebinding behaviour: https://forum.unity.com/threads/rel...meshpro-easily-display-your-bindings.1253292/

    The tool also allows you to display input bindings in textmesh pro texts by using the TMPro style tag. You can display a sprite for an action of an action map by typing <style=NameOfActionMap/NameOfAction> into a text field. This way you can have your bindings displayed in the same line as other text and don't have to mess around with positioning of text and sprites in your UI. Whenever the PlayerInput component detects a change to the active device (via the controls changed event), the displayed sprites will get updated to show sprites for keyboard or gamepads (XBox, PS or NS Pro)