I am a absolute beginner in unity. I have been working on an UI which is a simple login form. In which I have two Toggle
for selecting gender i.e male or female. Wh
I guess the two functions isMale and isFemale are Toggles' event handlers. According to Unity docs:
The Toggle has a single event called On Value Changed that responds when the user changes the current value
So the problem is that these event handlers respond to value change and not toggle being checked, so your code causes an infinite loop. It should work by reading them first to make sure it's a check and not uncheck:
public void isMale(){
if (!male.isOn) return;
if (female.isOn)
female.isOn = false;
male.isOn = true;
}
public void isFemale(){
if (!female.isOn) return;
if (male.isOn)
male.isOn = false;
female.isOn = true;
}