So what I’m trying to do is make a UI button appear when I set the player.SetActive(false)
I can’t see a problem with my code and I don’t get any errors. Can anyone see anything wrong with it.
Code:
void Respawn()
{
PlayerPrefs.SetInt ("lives", PlayerPrefs.GetInt ("lives") - 1);
//DontDestroyOnLoad (transform.gameObject);
Livestext ();
Application.LoadLevel(Application.loadedLevel);
}
void OnCollisionEnter2D(Collision2D coll)
{
if(coll.gameObject.tag == "Enemy")
{
player.SetActive(false);
LoseText ();
}
}
void OnGUI()
{
if(player.activeInHierarchy == false)
{
if(GUI.Button(new Rect(10, 10, 50, 50), "Try again?"))
{
Respawn();
}
}
}