Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Esophose · Apr 26, 2015 at 08:40 PM · buttoncrashtoggletoggle button

Toggle Button State On/Off

When I attempt to modify the variable "isOn" (On a Toggle) to either true or false after clicking on a toggle button, the Unity Editor becomes completely unresponsive and practically crashes.

When my scene first loads I modify Toggle Buttons to either an on or off state depending on what settings are saved in memory. When attempting to change these values, Unity throws thousands of errors and gives a StackOverflowException. My code that is throwing the errors can be viewed here http://pastebin.com/9ysYyKcX. You can figure out what lines are having issues in the Editor log that is attached to this post. Download the Editor.log: http://goo.gl/IIJufa

I am using Unity 5.0.1.

Thank you for the support!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by viesc123 · Jun 03, 2020 at 03:25 PM

Hey there.. notice that its already some time, since this has been asked, but I just came across a similar issue, so I'll try and answer this: The problem here is that changing Toggle.isOn will also call the OnValueChanged callback of the toggle. Assuming that this kicks off a chain of method calls that lead back to your initial call to Toggle.isOn, you'll end up in a nice endless recursive loop that will freeze Unity (or lead to a StackOverflowException if you're lucky). What you need to use instead, if you want to change the visual part of the toggle without the callback, is Toggle.SetIsOnWithoutNotify(bool isOn).

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image viesc123 · Jun 04, 2020 at 09:52 AM 0
Share

This method is for some reason is not listed in the script ref under Toggle.. I actually came across it, when I wanted to implement an extension method for toggle that did this.. and then found out that there is already a method with the same name XD

avatar image
0

Answer by johnnikson2012 · Feb 11, 2021 at 05:51 AM

Still face those who just add parent toggle group component and drag it in to child toggle group it will prevent to active only one toggle at a same time

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Toggle Button Question 0 Answers

GUI.Button Toggling Error 1 Answer

Is there a method to create toggle group behavior for standard buttons 1 Answer

Reset the last local players toggle button while keeping online players selection? 0 Answers

I'm trying to toggle my in-game menu. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges