Forum rules - please read before posting.

GUI: Toggle Group

Hi,

I'm trying to add a Toggle Group to some buttons. Essentially I have five buttons that can turn on/off certain screens, but only one can be opened at a time.

I've set up a Unity Toggle Group on the buttons, and in the scene where AC is not controlling the buttons, they work as they should. The buttons are toggles, they stay selected when clicked on, and you can click the same button again to turn it off. Clicking on Button A will make it appear selected, and Clicking on Button B will make it look selected, while deselecting Button A.

Now, in the scene where AC works properly, and the buttons are linked to AC Menus, I don't have this behaviour anymore. Clicking on the button keeps it pressed, and you can click on the same button to deselect it. However, if you click on Button A, it stays selected, but if I click on Button B, it doesn't get selected, instead it deselects Button A.

I'm not really sure how to get around this, as I don't see any relating options in the Toggle settings. I also don't see any Action that could check the state of a toggle. Any ideas how to get around this?

Comments

  • To be clear: you mention Buttons but are you using Toggle elements in AC's Menu Manager?

    Does your Toggle Group have Allow Switch Off checked, and what are your elements' Toggle type fields set to? AC doesn't currently account for Toggle Groups, as it controls/reads the Toggle directly. I shall look into this, however.

  • Sorry, I keep calling them buttons, but they all are actually all set up as Toggles. Even the AC Menu Elements are set as Toggle.

    And yes, I have Allow Switch Off checked in my Unity GUI.

    Toggle type fields are set to Custom Script, but they do run an ActionList when clicked (to turn on/off other menus).

  • Thanks. I'll attempt a recreation, but will let you know if I need more info.

  • What are your AC and Unity version numbers?

    I cannot recreate any issue, I'm afraid. Linking a trio of Toggle elements to Float variables causes all to behave as they should - as does a Custom Script with no event hook.

    AC doesn't control the state of a Toggle that wasn't clicked - so it may be down to your implementation of the OnMenuElementClick custom event.

  • Unity Version: 2018.2.18f1
    AC: 1.68.4

    What does OnMenuElementClick mean? Is that referring to the ActionList on Click in AC? Or is that a Unity thing for GUI (but that's called On Value Changed, on the Toggle Component)?

    "Linking a trio of Toggle elements to Float variables" float variables? Sounds like a step I missed on my side, unless that's something entirely different?

  • What does OnMenuElementClick mean? Is that referring to the ActionList on Click in AC? Or is that a Unity thing for GUI (but that's called On Value Changed, on the Toggle Component)?

    You've said your Toggle type fields are all set to Custom Script. This typically means behaviour is controlled via use of the OnMenuElementClick custom event.

    Custom events are a way of hooking up custom scripts to AC, and are run when AC performs common tasks. This particular one runs whenever a menu element is clicked on.

    Assigning an ActionList that runs upon clicking the Toggle is generally supplemental - not something that should control the Toggle's value itself. As I said, though, things worked for me when using the "Custom Script" option but without a custom event implementation. If you're not running an event, I'm not sure why you'd be getting the behaviour you are.

    "Linking a trio of Toggle elements to Float variables" float variables? Sounds like a step I missed on my side, unless that's something entirely different?

    That was just a test on my part, but it may be worth doing on your end. Toggle elements can be mapped to Boolean variables (sorry, not Float) so that clicking them affects an AC Global variable. Your "ActionList when click" could then read these variables and update other parts of your game accordingly.

  • Just managed to solve the issue!
    I was trying various custom scripts, but it always led to other problems.

    I've set up a set of new Toggles, added them to Toggle Group, plugged it in to AC menus and... It worked just fine. Eventually I realised that using ActionList on click: is what creates the strange behaviour - all I had to do to fix it, was to set each ActionList to Run In Background instead of Pause Gameplay. That allows me to turn on various GUI's and turn off all the other ones, while remaining the functionality of the toggles (and toggle group).

    I didn't set anything up in the OnMenuElementClick custom event.

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.