I’m been stuck on this silly bug for some time now and I can’t find an answer why it may have happened. I’m trying to do a very simple which is deactivating a panel GameObject using a coroutine (to allow the button SFX to play). Heres what I’m trying to do:
public class ExampleScript : MonoBehaviour
{
public GameObject confirmPanel;
public void CancelReturnToMenu()
{
StartCoroutine(CancelReturnToMenuTime());
}
public IEnumerator CancelReturnToMenuTime()
{
yield return new WaitForSeconds (0.25f);
confirmPanel.SetActive(false);
}
}
I’m calling the function CancelReturnToMenu() on my button via an OnClick event in Unity.
I’m not sure why this is not working, I’m not doing anything else. The coroutine is waiting 0.25 sec because I can hear the sound effect, however I’m not sure why the code after that line is not executing.
Thanks for the help