Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Why setting altNegativeButton in Input manager from code is ignored?

Discussion in 'Scripting' started by Chance-Touchstone, Aug 20, 2020.

  1. Chance-Touchstone

    Chance-Touchstone

    Joined:
    Dec 26, 2013
    Posts:
    43
    Hello, I'm trying to set an altNegativeButton value in the InputManager from code. Basically ANY altNegativeButton. The best example I could find was from the link below. But when using that example, none of the values in InputAxis set with .stringValue are applied. All of the bool, float, and int values are. WTH? Why is that.

    Please help, I'm using code from this link and Unity 2019.3.6f1 :
    https://plyoung.appspot.com/blog/ma...xQAnYej72_xMlatP_KCCPG3KRtdE2ic3pixYV8Tg_IBOE
     
    Last edited: Aug 22, 2020
  2. Chance-Touchstone

    Chance-Touchstone

    Joined:
    Dec 26, 2013
    Posts:
    43
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,517
    Not sure but I think modifying InputManager is only supported so you can do so in Editor scripts, not at runtime. I could be wrong about that, and I certainly do not see anything about it in the documentation, but I seem to distantly remember something about that from loooooong ago.

    Or maybe there's another bug. I've never manipulated the InputManager from code except in an editor script to query all the axes and store them in a string array. I rarely use the input manager myself, since I do mostly mobile development and make all my own touch controls for the precise experience I want.
     
    Chance-Touchstone likes this.
  4. Chance-Touchstone

    Chance-Touchstone

    Joined:
    Dec 26, 2013
    Posts:
    43
    Thanks Kurt.
    I figured out my issue. It was because the .stringValue values must be set in lower case. (face palm):oops:
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,517
    Interesting, can you elaborate please? Were you setting it to (for example)
    Alpha1
    (a valid KeyCode) and it instead has to be
    alpha1
    ? Or what do you mean exactly, in case someone else can benefit from your insight here.

    Glad it's working for you though! Good to know...
     
  6. Chance-Touchstone

    Chance-Touchstone

    Joined:
    Dec 26, 2013
    Posts:
    43
    Correct. I had to set the string with .ToLower() for it to recognize it.
     
    Kurt-Dekker likes this.