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. 3a14dd888e3786429407d4a45b016637?d=mm

    JoeysLucky22

    May 16, 2019 17:04

    Also voting for an earlier release for this fix.

  2. E27cc3d010bae81c759cee3c3a28de5e?d=mm

    Gloryiam

    May 16, 2019 16:42

    I posted in the forums about this here: https://forum.unity.com/threads/toggle-group-issue.679546/ - perhaps posting there also would get more attention from the Unity team?

  3. 34942f2b153cf0df8e48a46dba725233?d=mm

    juliocdep

    May 16, 2019 15:00

    I also vote for this fix to be released before the 2019.3. This problem breaks my game and I would not want to wait until the end of the year to use Unity 2019.

  4. 6b270fbb4402a5018762fc22d7f67529?d=mm

    jkieffer-filament

    May 15, 2019 18:41

    This is a pretty big bug for us too. Updating Unity for features that you need so often breaks other features that you also need. A fix sooner than 2019.3 would be very appropriate considering the drastic change in behavior.

  5. 2329e0c12e2169025ff6a517adef4a32?d=mm

    timmypowergamer

    May 15, 2019 17:03

    Agreed that 2019.3 is far too long to wait considering 2019.2 is still only in beta. We are talking months away for a fix that is literally game breaking for many of us. I would also appreciate if this could be fast-tracked a bit more, please. Thanks!

  6. E27cc3d010bae81c759cee3c3a28de5e?d=mm

    Gloryiam

    May 15, 2019 13:10

    I agree, this seems too big of an issue to wait until 2019.3 to have the fix. Sooner would be much appreciated :-)

  7. A28ce909c56fa0944fa83233d2ffd0da?d=mm

    HypergolicGames

    May 14, 2019 19:25

    I found this problem as well, I think it is also messing up drop down menus too. Its a bit of a game breaking bug as I can't get my game's settings menu to work properly. Please release a patch for this before 2019.3

  8. Ae3fbec0b5e9e4686c84676135ec349e?d=mm

    OkamiDMC

    May 14, 2019 11:49

    same problem to me

  9. E27cc3d010bae81c759cee3c3a28de5e?d=mm

    Gloryiam

    May 11, 2019 14:00

    Just noticed 2019.1.2f1 released today and this still isn't in the patch notes. In which version and when is this expected to be fixed?

  10. Edfc3b1034900db73e858f15c5b75915?d=mm

    wouter_vugt

    May 05, 2019 09:53

    also waiting for this, prevents me from releasing my app. Would like to know when or which version this is fixed in as well.

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.