Grady
1
hey guys,
i was wondering, is it possible to make a gui label dissapear after a certain amount of time???
i know how to use the GUI.Label() function, and that is what i am using, but i need it to dissapear after a couple of seconds of it appearing…
thanks
-Grady
opsive
2
I would use an invoke or a coroutine to toggle a switch between on and off… something like
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
private bool showLabel = false;
public void Start() {
Invoke("ToggleLabel", 2);
}
public void ToggleLabel() {
showLabel = !showLabel;
}
public void OnGUI() {
if (showLabel) {
GUI.Label(new Rect(10, 10, 100, 20), "Hello World!");
}
}
}
private var ShowlLabel : boolean = true;
function Start()
{
yield WaitForSeconds(your time limit);
ShowLabel = false;
function OnGUI()
{
if(ShowLabel)
{
GUI.Label(new Rect(10, 10, 100, 20), "Hello World!");
{
}