Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

OnToggleTap event is calling automatically when scene loading in Unity 2019.1

Discussion in 'UGUI & TextMesh Pro' started by sotrosh, Apr 22, 2019.

  1. sotrosh

    sotrosh

    Joined:
    Dec 25, 2014
    Posts:
    13
    Hi,

    After upgrading to Unity 2019.1 my toggles behaviour is weird. After each scene loading OnToggleTap(Toggle sender) is calling automatically. Please note that I'm programatically init toggles and adding it to the scroll list:
    Code (CSharp):
    1. for (int i = 0; i < musicModels.Count; i++)
    2.         {
    3.             MusicToggleScript musicToggleScript = null;
    4.  
    5.             GameObject newMusicToggleGO = Instantiate(this.musicToggleGO);
    6.             newMusicToggleGO.transform.SetParent(this.content.transform);
    7.  
    8.             musicToggleScript = newMusicToggleGO.GetComponent<MusicToggleScript>();
    9.             this.allMusicToggles.Add(musicToggleScript);
    10.  
    11.             musicToggleScript.UpdateWithMusic(musicModels[i], toggleGroup);
    12.         }
    13.  
    14.     public void OnToggleTap(Toggle sender)
    15.     {
    16.           // do something
    17.      }
     
    Last edited: Apr 22, 2019