Hello, I have a problem where I have an IEnumerator that’s called only once and then don’t work
public IEnumerator WrongLocking()
{
Frame[currLock].color = new Color32(255,0,0,255);
yield return new WaitForSeconds(0.1f);
Frame[currLock].CrossFadeColor(Color.black, 0.3f, false, true);
}
I tried to put it in the actual button method but it didn’t work either.
public void LockPosition()
{
if (Slider[currLock].value >= minGreen && Slider[currLock].value <= maxGreen)
{
LockButton[currLock].interactable = false;
Handle[currLock].color = new Color32(84, 255, 84, 255);
StartLockpick();
}
else
{
isRuined = true;
StartCoroutine(WrongLocking());
IEnumerator WrongLocking()
{
Frame[currLock].color = new Color32(255, 0, 0, 255);
yield return new WaitForSeconds(0.1f);
Frame[currLock].CrossFadeColor(Color.black, 0.3f, false, true);
coroutineSwitch = false;
}
}
}
Is there a way how to call this method more than once or is there any other option how to do that?