In my game I have a clock. When I press Esc, I open main menu and disable clock (images of the numbers and script, which make clock going). And when I press Esc again, clock became visible, but it don’t going because I launched coroutines in the script (in Start function) and after disable/enable object it didn’t launched again.
So is it any way to check in the script if object was enabled?
But not in Update function (with activeSelf), because I need to check if object enabled and launch coroutine only one time.
My code can’t restart coroutine, after it’s parent object was disabjed:
bool isClockStarted;
void Update()
{
if(gameObject.activeSelf &&
!isClockStarted)
{
StartCoroutine("Time000X");
StartCoroutine("Time00X0");
StartCoroutine("Time0X00");
StartCoroutine("TimeX000");
isClockStarted = true;
}
if(Input.GetKeyDown(KeyCode.Escape))
isClockStarted = false;
}