Forum rules - please read before posting.

Issue with Toggle, UnityUI and keyboard input

edited March 2018 in Technical Q&A
Hi again.

I have setup a Toggle in UnityUI with sprite swap transition and hooked it up to an AC menu. In AC I also defined an alternative input button for the toggle. I also made sure that in AC the keyboard input only calls this one toggle and nothing else.

When I click the toggle, everything works as intended. When I use the keyboard input everything but the sprite swap works.

I'm trying all this without writing any additional code, maybe it just doesn't work like this. Maybe I'm just missing a checkbox somewhere (there are a lot of those)!

Thanks again for any help!

Comments

  • The "Alternative input button" element property will cause the effects of clicking it to be made manually so far as AC goes.

    The value the Toggle is linked to will change, and the Toggle itself will update with the new checked state, but as the Toggle itself hasn't been clicked it won't play any Transition animation.

    AKAIK the transition behaviour is limited to clicking on the element directly, as it's all Unity internal.  You could try animating it by attaching an Animator component and then running that animation at the same time as the input button is pressed.

    You can make use of the OnMenuElementClick event to run code that triggers the animator when the element is invoked - this will run even when done through the alternative input button.

    A tutorial on custom events can be found here, while an example of the above event can be found in the "Custom interaction systems" chapter of the Manual.
  • edited March 2018
    Thanks, as always, for the response. I looked into the code for a bit, played around some more with various toggle options and the easiest workaround was to ... just do it with buttons.

    I don't intend to use this for more than a handful of slots at a time, so hardcoding "turn all the others off, when this one is clicked" into an action list is still okay. Sprite swapping is quite easy with manually toggling AC Menu Graphic elemets.
  • Just out of curiosity: does AC even support Unity UI Toggle Group funcionality?
  • As Toggle/ToggleGroup components reference each other directly, I'm not sure AC needs to interfere.  I shall check, however.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.