in my game after losing a level shows the restart button of the level . and the question is how to create a script that will show the restart button for example 3 times and after the fourth unsuccessful attempt will not show it anymore
this is my script to call the button:
else
{
yield return new WaitForSecondsRealtime(0.5f);
GameUI.ShowRestartButton();
and this is the button script:
public GameObject log2;
public void ShowRestartButton()
{
Destroy(log2.gameObject);
Image2.SetActive(true);
}
public GameObject logC;
private int deaths = 0;
public void ContinueGame()
{
if (deaths < 3)
{
Destroy(logC.gameObject);
deaths++;
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single);
}
}
because I’m mainly talking about the continue game button, which after three failed attempts disappears and tells the player to restart the game, but it doesn’t work and the button keeps showing up. Destroy LogC is that button