Hi there,
Does anybody know the order of Toggle methods execution.
I am having a script that runs in editors “onValueChange()”:
public void ffwd()
{
if (myToggle.isOn==true)
{
Debug.Log("FFWD");
audioPlay.pitch = 4;
}
else if(myToggle.isOn == false)
{
Debug.Log("FFWD back to normal");
audioPlay.pitch = 1;
}
}
This is a method in a script attached to the parent of the toggle.
What I am expecting is that by clicking 1st time the toggle (from off → on):
1st) IsOn to became true
2nd) Since (toggle.isOn == true ) → I expect to console to print “FFWD” and
3rd) pitch to go at 4.
And when I push toggle again,
1st) IsOn to became false
2nd) The Console to print “FFWD back to normal”
3rd) pitch to become 1
What I get is always the results for myToggle.isOn == false
(pitch to 1, and FFWD back to normal), even though the “isOn” in the inspector is being ticked. The only exception I got and get my method to work is momentary when I click the toggle very fast on and off.
What I am thinking is that maybe Unity first executes code and then turns toggle to true.
Could this be true, or I am missing something…?