Why does the Toggle Group always reset my default value

Hi all,

I recently used a toggle group with three toggles inside a panel. I set the first toggle as the default value by checking the "is On" check box in the inspector, and it worked well. But after I disactived the parent panel and reactived it again, the default value of the toggle group automatically changed to the third one. I could confirm this from the "is On" in the Inspector, and from the real game running scene.

Is it a feature or bug? My Unity version is 2019 1.0f2. Am I doing something wrong? What is the right way to set the default value to the first toggle?

When you stop running scene, anything what you set in inspector, gets reset to the point, what was set before running game.

If you want to store / save component data in inspector, either copy component at runtime, and paste it back when game stopped.
Or set data in inspector before running game, then run game.

Remember to save you changes in scene, when you happy. Unity don't save automatically.

Actually I did set the value before running the scene. I can confirm this behaviour from running the scence, and I can confirm from watching the inspector directly without running game too.

I do not know if you can reproduce this behaviour too as follows, but this is my steps:

  1. Create a panel
  2. Create 3 toggles as children of the panel.
  3. Create a toggle group as child of the panel
  4. Drag the toggle group onto the toggles.
  5. Choose the first toggle and check the “Is On” while leaving the other two’s blank.
  6. Back to the panel. Uncheck the box near the panel’s name to make it inactive.
  7. Check the box near the panel’s name to make it active again.
  8. Now watch the toggles. You will find the third one become “Is On” and the first one’s checkbox is blank. Quite puzzles me.

Can you post some screenshots?
You can simply paste them in post.
Don't need creating hyper links.

Here are the screenshots, showing the 5-8 steps in my last posts
1.

2.

3.

4.

![4561039--423814--14](Q%2ZHJ5@CRZ3U_T_CHF.png|864x257">
4561039--423820--T48L8F9PSQ5K)QPQASMO)}J.png
4561039--423823--2K}_3%E~)RUL}X)PYF_LM)U.png
4561039--423829--1$1AJ0BHTZM4(2D~65`4TJU.png

1 Like

~~Is On is part of the Toggle script isn't it?~~
~~Can you show scrpt?~~
~~Just remember to use code tags~~
~~** Using code tags properly .**~~
Edit:
Looks like bug too me.

You can use bug report
4561153--423856--upload_2019-5-20_18-51-56.png
with instruction to reproduce.

1 Like

I can verify this behavior.

I have a related issue that may help whoever is trying to fix this. (Are the debuggers reading this forum or do we have to submit a bug report somewhere?)

I'm working through the "Toggles and Radio Buttons" tutorial that starts on p. 74 of Smith's "Unity 2018 Cookbook". There is a script that prints a message whenever one of three toggles (Easy, Medium, and Hard) is turned on. The Easy toggle is the one that is set to Is On within Unity.

When I run the game, I get a message that the Medium button turned on, but nothing changes visually. By adding another print statement, I discovered that the Medium toggles is turning on and then off when the game starts.

When I exit game mode (having never actually clicked on any of the toggles nor seen any visual activity in the Game window), more spurious On Value Changed events happen: the Medium toggle reports that it has been turned on, then the Hard one.

1 Like

Same bug here

Same behavior here with Unity 2019.1.7

There must be definitely some bug in there, because moreover when you change the isOn value in Editor Mode, the Editor doesn´t think that has something to new to Save.

It’s a bug.

https://issuetracker.unity3d.com/issues/re-enabling-game-object-with-toggle-group-loses-information-about-previously-checked-toggle

Edit: And it’s now fixed in Unity 2019.1.10.

https://unity3d.com/unity/whats-new/2019.1.10

1 Like

This is NOT fixed (or has returned) in Unity 2020.1!

A
B == isOn
C

Toggle visibility

A
B
C == isOn

(C was never set isOn)

Confirmed not fixed in all of the 2019.3's and 2019.4's.

1 Like

I ended up making a better toggle & toggle group, has Sprites and color swaps, custom fade animation time, pressed/down sprite/color, no deselect bug:

https://gist.github.com/HolyFot/bcb98468200d02f083a0f03246206372

1 Like

I have updated the script: cleaned up warnings, fixed a selecting bug.

This bug still happened in 2019.4. I couldn’t choose the default toggle for my toggle group. Then I downloaded their Toggle scripts and fixed them by myself.

Still the same on Unity 2021 LTS

I had a similar bug in Unity 2022
finally found out that the "on value changed" mode of toggle was "Editor and runtime", and whenever I ended the game toggle was changing my setting to "on" ! (probably because of my default state of music toggle)

that also happens when I change the mode to editor and runtime when the game is not running and it instantly triggers my method and changes the setting
I took a screenshot of my logs when the game was not running:
9124084--1266217--toggleBug.jpg