I have a problem with my game. First run, play, and everything is fine. When there is an inscription "game over", press the button "back to main menu" and "play", the level is working, but do not run scripts.
My button looks like:
![alt text][1]
My code TimeManager looks like:
public class TimeManager : MonoBehaviour {
public GameObject player;
public GameObject gameoverText;
public GameObject resumeButton;
public Text timeText;
public int timePerLevel = 30;
private float clockSpeed = 1f;
void Awake ()
{
InvokeRepeating("Clock", 0, clockSpeed);
}
void Clock()
{
timePerLevel--;
timeText.text = ("Time: " + timePerLevel);
if (timePerLevel == 0)
{
//Destroy(player);
Time.timeScale = 0;
gameoverText.SetActive(true);
resumeButton.SetActive(true);
}
}
}
My menuevents file looks like:
public class MenuEvents : MonoBehaviour {
public void LoadLevel(int levelIndex)
{
Application.LoadLevel(levelIndex);
}
public void LoadLevel(string levelName)
{
Application.LoadLevel(levelName);
}
public void ExitApplication()
{
Application.Quit();
}
}
[1]: /storage/temp/48944-beztytułu.png
↧