- Home /
different objects with the same script wouldn't react correctly
I have the following code in a script attached to a few different objects.
public void ButtonClick(GameObject button)
{
if (isSelected == true){
if (!this.animation.isPlaying) {
this.animation.Play ("animation01");
}
}
}
and some code like the following in another script which in also being attached to a few game objects
public void Update()
{
if (radioButton._toggle.value == true)
targetEvent.Selected();
else targetEvent.UnSelect();
}
the Selected()and UnSelect() call are refering to the isSelected varieble in the former script. I was trying to use radio buttons to evaluate which object have been selected and play the animation when a gui button is clicked. all the references in the inspector are correct,even the isSelected states are working as expected, but the animation wounldn't play correctly. Is there a better way of doing this? any help would be appreciated.
Answer by evanchen · Oct 04, 2014 at 08:21 PM
ok,Solved! it turn out to be I've forgot the + sign in a NGUI click listener eg: UIEventListener.Get(gameObject).onClick += MyClickFunction;
Your answer