How do I add a message to the gui in the central part of the screen for five seconds, and then after five seconds, the message should disappear ?
X-raptor wrote:How do I add a message to the gui in the central part of the screen for five seconds, and then after five seconds, the message should disappear ?
Code:
var guiMessage : String;
var howlong : int;
var mystyle : GUIStyle;
var leveltoload : String;
function Start () {
}
function Update () {
}
function OnGUI () {
if(GUI.Button(Rect (Screen.width/2 - 50, Screen.height/2 + 10, 100, 50), guiMessage, mystyle)) {
Load();
}
}
function Load () {
yield WaitForSeconds(howlong);
Application.LoadLevel(leveltoload);
}
Code:
var guiMessage : String;
var howlong : int;
var mystyle : GUIStyle;
var leveltoload : String;
function Start () {
guiMessage = "";
}
function Update () {
}
function OnGUI () {
GUI.Label(Rect (Screen.width/2 - 50, Screen.height/2 + 10, 100, 50), guiMessage, mystyle);
guiMessage = "";
}
function GuiText () {
yield WaitForSeconds(howlong);
guiMessage = "";
}
Code:
var guiMessage : String;
var howlong : int;
var mystyle : GUIStyle;
var leveltoload : String;
var w = 0.3; // proportional width (0..1)
var h = 0.2; // proportional height (0..1)
private var rect: Rect;
function OnGUI () {
rect.x = (Screen.width*(1-w))/2;
rect.y = (Screen.height*(1-h))/2;
rect.width = Screen.width*w;
rect.height = Screen.height*h;
GUI.Label(rect, guiMessage);
GoOut();
}
function GoOut () {
yield WaitForSeconds(howlong);
guiMessage = null;
}