Hi everyone, I have an issue using Coroutines. Basically my problem is that I made a button prefab, with a fade effect when clicked. Now, I obviously made a script for this, two scripts actually, one is the one responsible for the instantiate of the prefab and controlling of events like mouse click etc. The other one is a controller, that stops and calls a coroutine when a certain condition is met.
Now, my issue is that if I instance another prefab of my button, and I click both of them, the first coroutine gets stopped, because the one on the other button has to start.
How do I avoid this? Can I just say that the coroutine has to end if the call is made from somewhere else?
I include the part of the script that manage the coroutine.
public function Fading(colorA : Color, colorB : Color, go : GameObject, animation_time : float)
{
var parameters : Dictionary.<String,Object> = new Dictionary.<String,Object>();
parameters.Add("ColorA", colorA);
parameters.Add("ColorB", colorB);
parameters.Add("GameObject", go);
parameters.Add("AnimationTime", animation_time);
StopCoroutine("FadeToColor");
StartCoroutine("FadeToColor", parameters);
}
I also would like to clarify that the controller uses a Singleton.
Thanks in advance.