Search Issue Tracker

Fixed in 2019.3

Fixed in 2019.1, 2019.2

Votes

28

Found in

2019.1.0a5

2019.1.0f2

Issue ID

1146883

Regression

Yes

Re-enabling game object with "Toggle group" loses information about previously checked toggle

uGUI

-

Steps to reproduce:
1. Open attached project "Test.zip"
2. Go into play mode
3. There are 3 toggles at the top, select a red one (row of red toggles should appear on the left side)
4. Check the first toggle on the left side row (You can check any toggle, but remember your choice)
5. Press green toggle (from 3 toggles at the top)
6. Press red toggle again (from 3 toggles at the top)
-The first toggle is not selected anymore from the left row, instead, another toggle is checked randomly. (Attached a video)

Explanation: Toggles at the top disable/enable "Toggle group" (only a single game object with toggle group is active at a time)

Expected result: After re-enabling element with "Toggle group" it shouldn't uncheck previously checked toggle
Actual result: Re-enabling game object with "Toggle group" loses information about previously checked toggle and instead checks random toggle in the group

Note: Sometimes it takes a couple of tries to reproduce the bug (repeat steps from 3rd step)

Reproduced on: 2019.1.0a5, 2019.1.0a6, 2019.1.0a11, 2019.1.0f2, 2019.2.0a1, 2019.2.0a10
Doesn't reproduce on: 2017.4.0f1, 2018.3.13f1, 2019.1.0a1, 2019.1.0a3, 2019.1.0a4
Regressed in: 2019.1.0a5

  1. Response avatar

    Resolution Note (fix version 2019.3):

    By default, ToggleGroup is coded to activate/deactivate the container for all associated Toggle elements. When the container is deactivated, all contained Toggles will get their OnDisable called. This will cause the Toggle to unregister itself from the ToggleGroup.

    When a Toggle calls UnregisterToggle() on it's ToggleGroup, it is removed from the ToggleGroup's internal list.

    Previously, any time UnregisterToggle() was called on a ToggleGroup that is set to disallow an off state, the group will then scan its list for at least one checked Toggle. Because the checked toggle is ultimately removed from the list before the list is totally emptied, the group will attempt to fix itself and set the first Toggle in the list to be On. This creates unpredictable behavior, both because the order of the list is non-deterministic, and because the first list element is rarely the value that should be set to On.

    This PR moves the logic for ensuring that one Toggle is marked On to a new function. The only times that this function actually needs to be invoked are:

    a) when the ToggleGroup gets its Start() method invoked. This will ensure that a ToggleGroup created in the Editor has a valid state when loaded.
    b) when a Toggle is deleted from the ToggleGroup. If the checked toggle is deleted programmatically or via the scene hierarchy, the list must choose a new one.

    New Toggles that are added programmatically will fix the state of the ToggleGroup as happened previously.

Comments (53)

  1. B665d1ab538b8024fdae133c6e10ccfb?d=mm

    Badaw

    May 03, 2019 08:57

    in which future release exactly has this been fixed ?

  2. 3911d6651bc24557569e6e950713b7be?d=mm

    gghitman69

    May 01, 2019 16:17

    Même problème pour moi. Lorsque le groupe de bascule est désactivé, la dernière bascule est cochée et la précédente est décochée.

  3. D55b32c29310d45b6eaf1386339c8cb9?d=mm

    Checko

    Apr 29, 2019 21:51

    Has anyone from Unity acknowledged this? Can we expect an update soon? This bug inhibits the ability to publish a game.

  4. 6b2d6ea98c9d40d08414101b5bd2429e?d=mm

    nixedd

    Apr 28, 2019 14:29

    i have the same problem! when will you fix it???

  5. 09f8c778627830db35bb907742329430?d=mm

    ReD_Energy

    Apr 26, 2019 22:10

    As everyone here stated... The bug it's really problematic. Can brake any project that uses ToogleGroups. Beside that, it can trigger certain behaviors multiple times because it checks everything again.

  6. 04e1fece394ddaebe130a31313a23ed4?d=mm

    dbchap

    Apr 26, 2019 22:06

    Bumping.. this is a real issue

  7. 66e0347540d6fc42d73dcff1ecb2df6d?d=mm

    Panzerhandschuh

    Apr 26, 2019 20:52

    I'm having a similar problem where destroying a toggle group internally tries to set one of the toggles on. But the toggle tries to refer to something that was destroyed and throws an error. I didn't have this problem in 2018.3.

    It's probably the same bug (OnDisable gets called when destroying the toggle buttons and toggle group).

  8. 88fd515b83b0552b50df0804b2a6cf46?d=mm

    waterbearpaul

    Apr 24, 2019 13:22

    Same problem for me. Had to implement ugly fix to keep it working.
    I also noticed that when you create a brand new toggle group, it does not bind to child Toggles anymore. You can easily verify it by activating Debug mode on Inspector.

  9. D18b6c027a4124fdd2d56afbc01d2750?d=mm

    Gamrok

    Apr 24, 2019 13:14

    Same problem for me. When the Toggle Group is disabled, the last toggle is checked and the previous one is unchecked.

  10. D55b32c29310d45b6eaf1386339c8cb9?d=mm

    Checko

    Apr 24, 2019 11:30

    We too are experiencing this problem. Unfortunately reverting back to 2018 is a large measure of work. I hope to see this resolved soon. One thing to note is that the unexpected behaviour is only when the toggle group "allow switch off" is unchecked. Checking this seems to work as expected. That however is not an option for our use case.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.