So I have this Text that I want to enable whenever something happens, but It doesn’t trigger the text.
But If I have this same text enabled and try to set it to FALSE it works.
something.SetActive (false); // WORKS when the object is enabled manually.
something.SetActive (true); // DOESN’T WORK when object is disabled.
@getyour411 I’m using the script on a different game object that has nothing to do with the gameobject I want to enable. I’m following the unity tutorials and tried to copy the whole code and I get the same error.
CODE:
public class GM : MonoBehaviour {
public int lives = 3;
public int bricks = 20;
public float resetDelay = 1f;
public Text livesText;
public GameObject gameOver;
public GameObject youWon;
public GameObject bricksPrefab;
public GameObject paddle;
public GameObject deathParticles;
public static GM instance = null;
private GameObject clonePaddle;
// Use this for initialization
void Awake ()
{
if (instance == null)
instance = this;
else if (instance != this)
Destroy (gameObject);
Setup();
}
public void Setup()
{
clonePaddle = Instantiate(paddle, transform.position, Quaternion.identity) as GameObject;
Instantiate(bricksPrefab, transform.position, Quaternion.identity);
}
void CheckGameOver()
{
if (bricks < 1)
{
youWon.SetActive(true);
Time.timeScale = .25f;
Invoke ("Reset", resetDelay);
}
if (lives < 1)
{
gameOver.SetActive(true);
Time.timeScale = .25f;
Invoke ("Reset", resetDelay);
}
}
void Reset()
{
Time.timeScale = 1f;
Application.LoadLevel(Application.loadedLevel);
}
public void LoseLife()
{
lives--;
livesText.text = "Lives: " + lives;
Instantiate(deathParticles, clonePaddle.transform.position, Quaternion.identity);
Destroy(clonePaddle);
Invoke ("SetupPaddle", resetDelay);
CheckGameOver();
}
void SetupPaddle()
{
clonePaddle = Instantiate(paddle, transform.position, Quaternion.identity) as GameObject;
}
public void DestroyBrick()
{
bricks--;
CheckGameOver();
}
}