I’ve searched google a few times for this with no luck but I want to delete a certain countdown GUI.Box after 5 seconds. But i cant find a way to remove a particular GUI.Box. Here is my code. i want the if (Ball_Movement.playerDead == true)
GUI.Box(new Rect(180, 400, 100, 20), “”+respawnCountDown);
to be deleted after 5 seconds. Also how do i force the textbox to read it as a int? right now that timer is showing up in my scoreboard script as a float countdown, i want it to be 1 2 3 4 5.
using UnityEngine;
using System.Collections;
public class ScoreBoard : MonoBehaviour {
// made your score static (changed it to score rather than scorboard global ur call)
//public static ScoreBoard instance;
public static ScoreBoard global;
public static float Score = 0f;
public static float Lives = 3f;
public static float respawnCountDown = 0;
public static float Timer = 0;
// Use this for initialization
void Start () {
//global=this;
}
// Update is called once per frame
void Update () {
if (Score >550) // should be 550
{
Application.LoadLevel("YouWon");
}
if (Timer == 5f)
{
// delete the particular gui box here
}
}
// Makes a GUI from the variable score which needs to be tied to when a block dies.
void OnGUI()
{
GUI.Box(new Rect(10, 0, 100, 20), "" + Score);
GUI.Box(new Rect(350, 430, 100, 20), "" + Lives);
if (Ball_Movement.playerDead == true)
{
Wait();
GUI.Box(new Rect(180, 400, 100, 20), ""+respawnCountDown);
}
}
void Wait()
{
respawnCountDown = Timer++ * Time.deltaTime;
}
}
You need to learn about the "Invoke" command, check it out
– Fattie