Sorry if I didn't my self clear, I'm making a switch, using the UISlider but with steps = 2, and it works great, and I want to play a sound when the value is changed, to accomplish this I call a method the value change from 0 to 1 or viceversa, the problem when I enable the GameObject the event onValueChanged is called and is played the sound when I didn't change the value.
I hope I make self more clear, if doesn't tell me and I will tried to make a video or mini example of what I'm talking.
To reproduce the problem that I'm having Just create a slider, and add this script:
void Awake()
{
EventDelegate.Add(GetComponent<UISlider>().onChange, OnValueChange);
}
public void OnValueChange()
{
Debug.Log("Hello");
}
then disable the gameObject of the slider, hit play, and enable the slider again, and you will see the hello printed when one didn't move the slider.