I copied a code from Brackeys that was supposed to wait before executing a function, but for some reason the Invoke function is not waiting. Both Debug.Log lines run right.
public float restartDelay = 2.0f;
public void EndGame()
{
if (gameHasEnded == false)
{
gameHasEnded = true;
Debug.Log(“GAME OVER”);
Invoke(“Restart”, restartDelay);
Debug.Log(“This should be working”);
}
}
Also this affects the lighting… Does the lighting problem affect the final game when I export it?
I’m in Unity 6 preview (6000.0.7f1) and this problem is still here.
void ShowSuccess()
{
Debug.Log("ShowSuccess".Color("green"));
defaultColor = border.color;
border.color = successColor;
Invoke("DefaultColor", 0.2f);
}
void DefaultColor()
{
Debug.Log("DefaultColor");
border.color = defaultColor;
}
Very rarely I get to see the color of the border change as it is immediately reverted to the original. Rarely, I see a little flicker of color for varying lengths of time. I just wrote this code and there is nothing else at all changing the color of that element.
I changed invoke to coroutine and WaitForSeconds and now it is very consistently showing the color and always for the same amount of time.