Search Unity

Toggles isOn state not changing after first toggle.

Discussion in 'Scripting' started by Seaworth, Sep 27, 2019.

  1. Seaworth

    Seaworth

    Joined:
    Aug 15, 2019
    Posts:
    19
    Hi all,

    I have three toggles placed in a ToggleGroup. The first time I click on a toggle the value in the source code below changes. If I click on another one and then click on the first one again it does not run the onValueChanged function again. Here is the code:
    Code (CSharp):
    1.     public void CreditsChanged()
    2.     {
    3.         if (twentyCredits.isOn == true) {
    4.             creditsSelected = 20;
    5.         }
    6.         else if (fiftyCredits.isOn == true) {
    7.             creditsSelected = 50;
    8.         }
    9.         else if (maxCredits.isOn == true) {
    10.             creditsSelected = 150;
    11.         }
    12.         Debug.Log("Selected: " + creditsSelected);
    13.     }
    So the first time I click on a Toggle, I see the Debug statement and the second time I don't. Any advice is greatly appreciated.
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    Is it possible that you have turned on "collapse" mode in your console, causing identical messaged to be grouped together?
     
    Seaworth and Dextozz like this.
  3. Seaworth

    Seaworth

    Joined:
    Aug 15, 2019
    Posts:
    19
    I had never paid attention to Collapse. Thank you!