Search Unity

Input - Get key/button bindings?

Discussion in 'Scripting' started by Todd-Wasson, May 5, 2015.

  1. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Is there a way to get the keys/buttons/axes that the user selected during the game start up for inputs and display them in this UI?



    Originally I wanted the controller setup to be done inside the game through a screen like this, but it's looking a lot harder to do than I initially thought since it seems most of the InputManager stuff is hidden away. I don't see a way to change controls easily and am a little mystified as to how the input managers on the asset store are doing what they're doing.

    For now I've decided to just cue the player to restart the game and use the standard input window instead, then show their current controls in this screen in case they forget what does what.

    I'm not seeing anything in the Input class to do this, though. What I want is to change the "key" column in this screen to the current key and controller axis mappings. Does anyone have any ideas on how this might be done?
     
  2. relic1882

    relic1882

    Joined:
    Mar 11, 2015
    Posts:
    45
    As far as I was looking into before it's not available to be able to change inputs to your liking very easily. The easiest way is probably for you to check out what "Input Managers" people have made already from the Asset Store.
     
  3. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Thanks. I tried a few of the free input manager assets and am having a tough time finding anything that works with the Unity 5 betas. I tried this https://www.assetstore.unity3d.com/en/#!/content/34033 which apparently was updated just today, but Unity said "You are trying to import an asset which contains a global game manager. This is not allowed."

    So either the free packages don't seem to work at all with Unity 5 or they use old GUI stuff that doesn't work, or, or or... So at this point I don't dare buy any of the packages.

    It just seems odd that the Unity input manager is so locked up. I'd think you'd be able to at least read the bindings even if you couldn't change them due to internal complexity.

    Oh well, I guess I'll just remove my "keys" stuff and leave this screen with the instructions saying to restart Unity. It's a shame though, it'd have been nice to at least show what keys and buttons do what.
     
  4. relic1882

    relic1882

    Joined:
    Mar 11, 2015
    Posts:
    45
    Sorry to hear that. I never used one but I read in another post somewhere that one of the paid Input Managers was pretty good but it was 30 bucks. I'll pass until I really need it lol. :)
     
  5. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    If it was just a matter of buttons and keys, this wouldn't be too hard to do myself by bypassing the built-in input manager completely and just storing keycodes and so forth, essentially duplicating the built in input screen at startup. Using Input.inputString would be a simple way probably. I started to do that, but quickly realized I couldn't find a way to read the individual joystick axes directly in order to poll them for a controller setup screen. Without that, a setup screen where you could actually change the inputs seemed pointless.

    It seems people have been asking for this for at least five years with a "planned" status. It's such a basic, everyday gameplay thing I'm really surprised it's not there.

    Oh well, I guess I'll just have to stick with the default Unity stuff and somehow inform the players that there are controls for this and that doohickey, but they'll have to restart the game to even see what those controls are if they're not set to the defaults.

    As for the paid assets, I don't have a problem paying $50 or more to save me a few weeks (or even hours or days) of trying to do it myself, but I need to be able to demo it somehow at least given everything I've tried so far is broken. Hmmf.. o_O
     
  6. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Here we go. :D

     
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Yup. It sucks. And is probably Unity's biggest failing as an engine. Everything else is pretty great.

    You are going to have to do a hacky work around if you want configurable input. I use OnGUI and intercept the keypress events. Its ugly, but it works.

    For joysticks I'd suggest a layer of misdirection.